i have a css prop like stated
#menu li#selected { padding: 0 10px; margin:0; background:url(nav-tab-left.gif) bottom left no-repeat #90288d; height: 35px; }
after the li i need to display the second part of the image nav-tab-right.gif
i try
#menu li#selected:after { background:url(nav-tab-right.gif) bottom right no-repeat; }
but this returns inconclusive
Building from your previous question‘s HTML.
IE7 and below doesn’t support the
:afterpseudo-element. Use something like this instead:HTML:
CSS:
This will work in all browsers and doesn’t rely on
:afterwhich IE7 and below doesn’t support.Hover Variation
Another advantage of using this method is that you can modify it slightly to allow for CSS rollover images that will be compatible with IE6 as such:
HTML:
CSS:
Yes, it does work on IE6 and below (and above) since
ais the only element for which IE6 supports the:hoverpseudo-class. It is also the reason why this method requires adding an additional<span>tag as we cannot target the<li>with:hoverin a way which IE6 understands.I do recommend using CSS sprites instead of separate images for the hover effect, but to keep this example as simple as possible, I will keep it as such.
For more information about CSS selectors support, see CSS – Contents and compatibility.