我有这个HTML代码:
<div class='ui'>
<h3 class='title'>
<a href='#'>Link to Header</a>
</h3>
</div>
<a href='#'>Another link</a>
Run Code Online (Sandbox Code Playgroud)
我想为所有锚点a设置一个CSS样式,但不是为一个h3元素设置为div.ui的父元素.我不能将一个类添加到锚a到h3元素中.
我试试这个:
a:not(:parent:parent.ui){color:#dedede;}
Run Code Online (Sandbox Code Playgroud)
但这不行.有解决方案吗
正如科比在评论中指出的那样,没有这样的:parent选择者.
相反,我建议您设置所有a标签的样式,然后在不同规则a内的h3标签内设置样式标签:
a {
color: #dedede;
}
.ui h3 a {
color: another color;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1695 次 |
| 最近记录: |