嗯......你首先需要一个白色图标:)
然后只需为状态添加以下样式active
:
.university.active{
color:white;
margin-left:-12px;
background: url('URL_WITH_WHITE_ICON') 210px center no-repeat;
}
活生生的例子: http: //jsfiddle.net/vvvRX/1/ (用于第二个按钮)
另外,请注意,您padding
不止一次使用 id ......它应该是一个类。
更新
如果你想同时保留两个背景,那么你就有麻烦了。您需要使用:before
或:after
属性,许多旧版本的浏览器不支持这些属性。
标签的相对位置: label { color:#40403e; 背景:#dbdcd4;位置:相对;}
:after
以及具有新背景的样式:
.university.active:after{
content:'';
position: absolute;
z-index:3;
color:white;
right:-12px;
top:-2px;
background: url('http://www.maxwellplan.com/fw/img/university-check-icon-white.png') 210px center no-repeat ;
width:100%;
height:100%;
}
活生生的例子:http: //jsfiddle.net/vvvRX/3/
更新 2
您的主要问题是您的 HTML 代码。如果您刚刚正确创建它会简单得多。例如,对项目使用列表并为右侧的图标添加 span 元素。然后,您可以单独使用列表背景或活动状态的跨度背景。
好吧,我不会向您解释一切,而只是看看应该如何做:
http://jsfiddle.net/vvvRX/4/