html - 仅将 css 分配给 p 而不是特定的 p.class

标签 html css css-selectors

在我的 html 页面中有两种类型的 <p> -

  • 一个是 <p class="header"> for some Paragraph in header</p>
  • 和其他人只是<p>Containing some text </p>

我想要一个 color对于唯一p (应该是一些 #xxxxx )和 p.header它应该是默认颜色。

这是我的CSS:

p {
    margin-bottom:18px;
    line-height:180%;
    color:#xxxxx;
}

我想要的是,这个 css 不应该应用到 p.header它应该使用浏览器的默认样式。有没有办法只选择p不在 p.header 中? 喜欢

      p:not("p.header"){ 
            margin-bottom:18px;
            line-height:180%;
            color:#xxxxx;
      }

我们也可以使用它吗,p:not(.header, .sub-title){}

最佳答案

 p:not(.header) { 
            margin-bottom:18px;
            line-height:180%;
            color:red;
 }

只是删除了引号和 p

fiddle here

关于html - 仅将 css 分配给 p 而不是特定的 p.class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26032615/

相关文章:

php - 不要使用 JavaScript 提交 MYSQL 数据库中的现有值

html - 新行中第一个和最后一个内联 block 元素的选择器

jquery - CSS - 选择器的使用不正确?

html - 针对表单中的最后一个表单字段,然后是一些

html - 为什么我的第 nth-of-type 伪类不选择第一个 a,并将其视为第 4 个?

javascript - 有没有办法用 Angular "pagin"html 表隐藏最后一个元素?

html - 如何缩进段落中除第一行以外的所有文本?

html - 使 div 占据边距未使用的全部空间

javascript - 展开导航强制滚动到打开时的顶部

css - 如何使 SVG 路径中的文本居中