by ryankshaw · 14y ago · 0 comments
http://www.nczonline.net/blog/2010/07/06/data-uris-make-css-...
this stack overflow answer brings up 2 possible drawbacks of a data-uri based approach: http://stackoverflow.com/a/3525961/897583 but it seems like if you are worried about your other css rules being blocked by your data-uri background-images, either put them in a css file that loads after your important rules, or just put them at the bottom of the css file. and it seems like with gzip the increase in size is negligible.
edit: oh, so i didn't fully grasp what your comment was saying. are you suggesting that you would use inline-image AND a sprite to put all the images into a sprite AND load that sprite inline with the css?
as far as keeping it simple, the sass file that I would write would look like:
.icon {
height: 16px;
width: 16px;
display: inline-block;
}
.checkmark-icon {
@extend .icon;
background-image: inline-image('path/to/checkmark.png');
&:hover { background-image: inline-image('path/to/checkmark-hover.png'); }
}
.error-icon {
@extend .icon;
background-image: inline-image('path/to/error.png');
&:hover { background-image: inline-image('path/to/error-hover.png'); }
}
so you'd never have to manually update the sass file if the image changes and then you can just do some magic to get it to work with ie7 with mhtml if you are going to support it.I'm not sure about the slightly larger filesize, but it's worth it for the other benefits.