:not 选择器

来源:互联网 发布:linux网络书籍 编辑:程序博客网 时间:2024/06/05 23:40


:not(selector)选择器匹配非指定元素/选择器的每个元素。

非最后一个p标签设置颜色为红色。

<!DOCTYPE html><html><head><style> p:not(:last-child){background:#ff0000;}</style></head><body><h1>这是标题</h1><p>第一个段落。</p><p>第二个段落。</p><p>第三个段落。</p><p>第四个段落。</p><p>第五个段落。</p></body></html>

原创粉丝点击