[英]Apply CSS properties to class but only if element has another specific class
I have this html: 我有这个HTML:
<li class="arrow branches"></li>
<li class="arrow branches"></li>
<li class="arrow branches"></li>
<li class="arrow"></li>
<li class="arrow"></li>
<li class="arrow"></li>
I want to give css commands only for "arrow branches" classes,how can I give them css that wont effect the "arrow" classes? 我只想为“箭头分支”类提供css命令,如何给它们提供不会影响“箭头”类的css?
Create the class .branches
: 创建类.branches
:
.branches{
color:#f00;
}
If you want to apply it to only those elements that have branches and arrows then put them together: 如果要仅将其应用于具有分支和箭头的元素,则将它们放在一起:
.arrow.branches{
color:#f00;
}
But if you want to apply it to more than one class thats easy too: 但是,如果您想将其应用于多个类,这也很容易:
.branches, .otherClass{
color:#f00;
}
It's extremely simple: 这非常简单:
li.arrow.branches
{...styles...}
This selects LI elements with the classes branches AND arrow, but not arrow on its own. 这将选择具有类分支AND箭头的LI元素,但不能单独选择arrow元素。
.arrow.branches { // your css }
仅适用于两个类的元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.