Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Simple Sprite Not Working Re: Simple Sprite Not Working

#77107
chrisburton
Participant

I’m confused by your response as the code below basically does what you’re asking. Your markup is invalid as I’m pretty sure you cannot have a div inside header tags. And the image sprite will only appear with an H1 class of home (h1.home) and an H2 class of news (h2.news)



Welcome


Latest News



/***** CSS *****/
h1.home:before,
h2.news:before {
content:"";
display: block;
float: left;
width: 50px;
height: 50px;
margin-right: 20px;
background: url("/SPRITE/URL/image.png")no-repeat;
}

h1.home:before { background-position: 0 0; }
h2.news:before { background-position: -50px 0; }