我想创建一个动态图标使用css精灵。这里就是我不断收到:css图像建设与精灵
所以我其实有什么地方出了错几个问题:
- 为什么图标(跨框)不重叠的紫色盒子?
- 为什么紫色的盒子之间有2px的空间?
编辑
这里是一个的jsfiddle:http://jsfiddle.net/hWhUb/
这里的初步认识CSS我正在使用:
.icon {
position: relative;
width: 87px;
}
.icon .icon-type {
position: absolute;
left: 0;
}
.icon .brigade, .icon .icon-type {
background-image: url('img/play/splitbrigades.png');
}
.icon-hero {
width: 87px;
height: 71px;
background-position: -11px -11px;
background-repeat: no-repeat;
}
.brigade-purple-left {
width: 27px;
height: 71px;
background-position: -287px -12px;
display: inline-block;
background-repeat: no-repeat;
}
.brigade-purple-middle {
width: 30px;
height: 71px;
background-position: -334px -12px;
display: inline-block;
background-repeat: no-repeat;
}
.brigade-purple-right {
width: 28px;
height: 71px;
background-position: -384px -12px;
display: inline-block;
background-repeat: no-repeat;
}
和HTML:
<div class="icon">
<div class="brigade brigade-purple-left"> </div>
<div class="brigade brigade-purple-middle" style="width: 22px;"> </div>
<div class="brigade brigade-purple-right"> </div>
<div class="icon-type icon-hero"> </div>
</div>
任何人都可以向我解释我做错了什么,也可能如何以更好的方式实现我的结果(如果可能的话)?
哪来的原始精灵不会呈现“上面”的盒子?如果你可以把所有的东西变成一个jsfiddle,这将会非常有用,谢谢! – Luca
更新与小提琴链接 – LordZardeck