CSS选择器基于条件 [英] CSS selector based on a condition
本文介绍了CSS选择器基于条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图获取一个CSS选择器来检查和应用CSS基于条件,如果: sectionContent-noToolbar
可用,然后应用 height:2em
在 sectionSeperator
。是可能实现使用一些选择器?我一直在寻找答案相当一段时间,现在没有任何运气。任何建议?
I am trying to get a CSS selector to check and apply the CSS based on the condition that if: sectionContent-noToolbar
is available, then apply height:2em
on sectionSeperator
. Is it possible to achieve that using some selector? I have been searching for an answer for quite a while now without any luck. Any suggestions?
<section class="sec" name="Information">
<div class="sectionContent-noToolbar"></div>
</section>
<div class="sectionSeparator"></div>
推荐答案
不,不是。
如果他们是兄弟姐妹,那么你可以使用相邻的兄弟姐妹组合器:
If they were siblings, then you could use the adjacent sibling combinator:
.sectionContent-noToolbar + .sectionSeperator {
height: 2em;
}
...但是CSS没有任何东西可以让你根据它的兄弟姐妹后代修改一个元素。
… but CSS has nothing that lets you modify an element based on its siblings descendants.
这篇关于CSS选择器基于条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文