gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 23:28:29 25 4
gpt4 key购买 nike

在我的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com