有没有办法根据设置为两个特定类的类属性的值来选择具有CSS的元素.例如,假设我有3个div:
<div class="foo">Hello Foo</div>
<div class="foo bar">Hello World</div>
<div class="bar">Hello Bar</div>
Run Code Online (Sandbox Code Playgroud)
我可以写什么CSS来选择列表中的第二个元素,基于它是foo和bar类的成员这一事实?
假设我们有这个标记:
<div class="abc"> ... </div>
<div class="xyz"> ... </div>
<div class="abc xyz" style="width: 100px"> ... </div>
Run Code Online (Sandbox Code Playgroud)
有没有办法只选择<div>哪个有BOTH abc和xyz类(最后一个)并覆盖它的内联宽度,使有效宽度为200px?
像这样的东西:
[selector] {
width: 200px !important;
}
Run Code Online (Sandbox Code Playgroud)