如何从特定类型中获取第一个元素。
h1:first-of-type {
background: red;
}
<h1>Main Title</h1>
<div class="content">
<h1>Another Title</h1>
<div class="para">
<h1>One More Title</h1>
</div>
</div>
我想设置“主标题”h1
,背景为红色。问题是所有三个 h1
background:red;
最佳答案
试试这个
CSS
.content h1{
background:none;
}
HTML
<h1>Main Title</h1>
<div class="content">
<h1>Another Title</h1>
<div class="para">
<h1>One More Title</h1>
</div>
</div>
关于html - 整个页面的第一个类型 css3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17271235/