Blog

Background Position with Ids and Classes

00:16 Saturday, October 17

I'm currently working on a new layout for my website, a bit more simplistic than this crazy paint-themed one. I was working on implementing CSS sprites for my links and ran into a problem. For some reason, I wasn't able to change the background-position on my anchor tags when I referenced them using a class. For example:

.listButton {
background-image: url('someimage.gif');
background-position: 0 0;
display: block;
}

.listButton:hover {
background-image: url('someimage.gif');
background-position: 0 -34px;
display: block;
}

didn't work. But this:

#listButton {
background-image: url('someimage.gif');
background-position: 0 0;
display: block;
}

#listButton:hover {
background-image: url('someimage.gif');
background-position: 0 -34px;
display: block;
}

does work! Interesting...

comments