第一个div是这样的
<div class="item ui-droppable feed masonry-brick">
第二个多了一个小类
我想在类选择器较小时修改降序元素,并将颜色更改为黑色/这些元素的属性。
我已经尝试了以下但没有成功:
.item .more .deliverytype {
color: red;
display: inline;
font-size: 20px;
font-weight: 500;
position: absolute;
right: 7px;
text-align: right;
top: 54px;
}
.small .deliverytype {
color: black;important!
}
最佳答案
只是更具体 - 不需要 !important
, 只需使用 .small.item
.
.small.item .more .deliverytype {
color: black;
}
jsFiddle here - 它有效。
自 color:red
正在通过 .item .more .deliverytype
设置,您只需要添加 .small
.因此,如果父级同时包含 .small
和 .item
( .small.item
),它将设置 .deliverytype
的样式这是 .more
的后代.
关于css - 两个相似的 div 元素,一个有一个额外的类如何覆盖降序元素的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19507813/