Hi all,
I've got a sprite with a few icons on it that I'm trying to implement on my site. They are used in multiple places on the page and need to have different properties. Sounds simple enough, but I'm having trouble finding the right selectors to get this to work. Here's how things are layed out:
<body>
<aside id="sidebar">
<ul> <!-- for nav links -->
<li>
<div class="icon icn_new_article"></div> <!-- example class and icon -->
<a href="url">New Article</a>
</li>
</ul>
</aside>
<section id="main">
<table>
<tr>
<td><div class="icon icn_jump_back"></div>Reply</td
</tr>
</table
</section>
</body>
And the basic CSS is this:
.icon {
background: transparent url(../images/icn_sprite.png) no-repeat;
width: 17px;
display:inline-block;
margin-right:-17px;
margin-bottom:-4px;
}
.icn_add_user { height:17px;background-position: 0 -126px; }
, for example. So the problem I'm facing is that, specifically, the margins are different for the sidebar and the table uses. I've tried doing #sidebar .icon
and #main .icon
to specify the different margins, but then the background-position
property from the rest of the definitions are ignored and set to 0,0.
I could just override the margin-right property inline with style="margin-right:0px;"
but that seems unnecessary. Thanks in advance for your help.