如果兄弟元素存在于PURE CSS中,则有条件地设置样式
这个问题在这里已经有了答案:
一般来说,没有。 CSS向前/向下读取DOM - 它不会向后/向上读取。 但是通过这个标记,你可以使用:not(:last-child)
.firstElement:not(:last-child) {
color: red
}
<div class="wrapper">
<div class="firstElement">target this</div>
<div class="secondElement"></div>
</div>
<div class="wrapper">
<div class="firstElement">not this</div>
</div>
链接地址: http://www.djcxy.com/p/22853.html
上一篇: Conditionally set style if sibling element exists in PURE CSS
下一篇: What is the difference between Normalize.css and Reset CSS?