我想将:not
伪代码应用于li
和[aria-hidden=true]
属性。但它不起作用。请看下面的代码。
HTML:
<li class=" timeframe"><h5 class=" timeframe-title">Jun<span>2015</span></h5>
<ol class=" milestones">
<li class="milestone-wrapper even"></li>
<li class="milestone-wrapper even" aria-hidden="true"></li>
<li class="milestone-wrapper odd" aria-hidden="true"></li>
<li class="milestone-wrapper even" aria-hidden="true"></li>
</ol>
</li>
CSS:
.milestones .milestone-wrapper:not(li[aria-hidden=true]) {
padding-bottom: 40px;
margin-bottom: 0px;
color:red;
}
答案 0 :(得分:4)
来自MDN/CSS/:not:
否定CSS伪类:not(X),是一个功能符号,它将一个简单的选择器 X 作为参数。
...
语法::not(selector){style properties}
[aria-hidden=true]
本身就是selector。从li
移除:not(li[aria-hidden=true])
:
.milestones .milestone-wrapper:not([aria-hidden=true]) {
padding-bottom: 40px;
margin-bottom: 0px;
color:red;
}
&#13;
<li class=" timeframe"><h5 class=" timeframe-title">Jun<span>2015</span></h5>
<ol class=" milestones">
<li class="milestone-wrapper even"></li>
<li class="milestone-wrapper even" aria-hidden="true"></li>
<li class="milestone-wrapper odd" aria-hidden="true"></li>
<li class="milestone-wrapper even" aria-hidden="true"></li>
</ol>
</li>
&#13;