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

时间:2014-09-25 07:06:02

标签: 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){}吗?

2 个答案:

答案 0 :(得分:2)

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

刚刚删除了引号和p

小提琴here

答案 1 :(得分:1)

p:not(.header) {


 your properties
}

那应该有用......