Great to see an example of one option. I know how to do it with JavaScript but I want to know if there is a way to change the image in my menu only with CSS.
The only thing you can do is hide and show images, not replace them. However, I guess what you could do is apply a background image to the the anchors (make them display as block element before) and on hover you hide the HTML image with visibility: hidden, revealing the background image in the anchor(s).
Am I writing the background image wrong in css? Because now only the image that I declared in my HTML appears. With mouse over it takes away the image (in a blinking kind of way). So the background image that I declared in my CSS dosen´t appear at all, why?
Because you assigned the IDs to the images but in the CSS you address anchors inside elements with the respective ID. Move the IDs to the list items and it should work.
It seams strange that in Internet Explorer (7) the three last topics in the menubar works exactly as I want! But two topics only get invisible.
In firefox the three pictures declared in the css is laying under the pictures in the HTML but they are positioned right under so you can see a little part of them..
For me the topics are declared in the same why so I don´t understand why they are working diffrent. Schould I put a position to the image in the CSS to make them be exactly under the other picture?
were I try to make the code work if somebody have any idea why only the last three of the background images is showing up on mouse over and why the position is "wrong" in firefox?
As I said earlier, your links must be displayed as block elements. Likewise, your list items should be displayed as such, and to get them next to each other float them to the left (if you use float you don’t need display: block;).
Thank you VIPStephan for your patience, knowledge and explanations!
I have giving myself some time to try to find the answer of why my backgrounds image don´t show up so I don´t ask to stupid quiestions here!
Now I have; img tags, id:s in the li tag of the backgroundimage, an img:hover of visibility: hidden and a float in the css.
I have made the layout look the same both in IE and firefox (finally!) But now none of the browsers will show the background image on mouse over(hover). On mouse over it blinks and I think sometimes a see the background color in the blinkings..! But after the blinking only the background color is shown.
Have I missed something? I really liked your solution on this VIPStephan and it would be awesome to make it work! Check my codes out: www.koanuka.com/webtv/test.html
Last edited by Energia; 07-29-2011 at 04:37 PM..
Reason: Link to testpage
address list items inside elements with the respective ID. However, the list items themselves have the IDs so you should remove the “li” declaration from these rules so that only the ID remains, like #photos {…}
I´m a fan of you VIPStephan!
You gave me many "aha! times"
Now it works! Sometimes it gives a little blink still, but I read something that it´s the time it take for the browser to load the image..?
If you have something to add about that your welcome but I´m glad that you had a way to do this with only HTML and CSS, and it looks the same on IE and firefox