如何将样式应用于除第一个元素以外的所有元素:
<div class = "mm-current" id="mm-1"></div>
<div class = "mm-current" id="mm-2"></div>
<div class = "mm-current" id="mm-3"></div>
...// Dynamic amount of entries我已经尝试过了:
.mm-current:not( #mm-1 )
{
background-image: url( "Images/trans-white-background-strong.png" ) !important;
}但不幸的是,这并不起作用(无论元素上是否包含id="mm-1",都会应用样式)
发布于 2015-08-20 22:52:30
在使用类时,只将样式应用于第一个元素,请执行以下操作:
.mm-current:first-child
{
background-image: url( "Images/trans-white-background-strong.png" )!important;
}希望你的问题解决了,问候。
编辑#1:当你只想要一个元素的特定样式时,你可以做同样的事情。没有风格也是一种风格,如果你明白我的意思:
小提琴:http://jsfiddle.net/3zvg5f6b/1/
摆弄图片:http://jsfiddle.net/3zvg5f6b/2/
https://stackoverflow.com/questions/32121476
复制相似问题