Reputation: 1534
I have the following css using Sass, but for some reason I only get 1 image, don't even know for which element is adding this.
ul {
position: relative;
li {
font: normal 18px/22px Arial, sans-serif;
list-style-type: none;
}
li:before {
background: url(img/sprite2.png") no-repeat scroll -372px -391px rgba(0, 0, 0, 0);
content: "";
height: 25px;
left: 0;
position: absolute;
top: 8px;
width: 20px;
list-style-type: none;
}
}
Upvotes: 1
Views: 182
Reputation: 1244
Remove the "top" from the styles and you're fine. Here is a jsFiddle: http://jsfiddle.net/4L9je4tx/
ul
{
position: relative;
}
li
{
font: normal 18px/22px Arial, sans-serif;
list-style-type: none;
}
li:before
{
background: url("img/sprite.png") no-repeat scroll -372px -391px rgba(0, 0, 0, 0);
content: "";
height: 25px;
left: 0;
position: absolute;
width: 20px;
list-style-type: none;
}
Upvotes: 1
Reputation: 193291
Since li:before
are absolutely positioned, you need to make every li
positioned relatively, so that corresponding :before
was positioned relatively to its parent li
. Otherwise all :before
pseudo-elements are positioned relatively to ul
, and of course they are all stacked on top of each other.
li {
position: relative;
font: normal 18px/22px Arial, sans-serif;
list-style-type: none;
}
Upvotes: 1