I have created a site that uses rollover images as the main links but what i would like to know is how i make the active link the same as the hover link so that when i go to the page that link remians the correct image instead of going back to the image before rollover. I have tried this in css and created a clear png as the link image and then assigned the class to is from the style sheet like this, .dog a{ display:block; background-image:url(images/1.jpg); background-position:top; } .dog a:hover{ background-image:url(images/index_03.jpg); display:block; background-position:top; } .dog a:active{ background-image:url(images/index_03.jpg); display:block; background-position:top; } Code (markup): I am not sure if this is the right way about it but i need the rolloever image to remain high lighted on the active page
you need to use a current link. <li class="current">page</li> and style the .current { background-image: etc }
I think you're looking for this: .dog a:visited{ background-image:url(images/index_03.jpg); display:block; background-position:top; }
<a id="dog" href="#foo">dog.</a> a#dog { background:url(../images/normal.jpg) no-repeat; display:block; width:100px; height:100px; } a#dog:hover { background:url(../images/rollover.jpg); }
I actually suggest you use a single image for the rollover, so you don't have to waste the server's time grabbing multiple images, have it send those images to the browser, and then waste the user's time as the browser downloads them (as can happen with dialup users such as myself). Paul O'Brien has a wonderful example of this (bear in mind his example supports Mac-IE, which is a dead browser; if you want to use a SPAN instead of EM, feel free to). http://www.pmob.co.uk/temp/navimagereplace.htm The only thing I'd do to give the menu item the effect you want is to add an ID of "current-page" (or "current", or whatever value works best for you) to the list item, and then style the image's position so that the hover state is present by default. But then again, I'd set the image to have three states (static, current, hover) so that there's some variation and you don't confuse your site's visitors.