Saturday 24 September 2011

CSS Z-Index Question?

So I have a question. I have a page that has %26quot;tabs%26quot; up top, which is the navigation. Code:



a:hover

{

position:relative;

top: -5px;

}



That makes it move up, obviously, whenever you hover over it. However; the problem is that when you're on a page, I want the z-index to be positive; like tabs in a notebook.



Code for that:



%26lt;div id=%26quot;top_nav%26quot;%26gt;

%26lt;a href=%26quot;template.html%26quot; style=%26quot;z-index:10;%26quot;%26gt;

%26lt;img src=%26quot;../images/blog.PNG%26quot; width=%26quot;100%26quot; /%26gt;%26lt;/a%26gt;

%26lt;a href=%26quot;template.html%26quot;%26gt;

%26lt;img src=%26quot;../images/bios.png%26quot; width=%26quot;100%26quot; /%26gt;%26lt;/a%26gt;

%26lt;a href=%26quot;template.html%26quot;%26gt;

%26lt;img src=%26quot;../images/gigs.png%26quot; width=%26quot;100%26quot; /%26gt;%26lt;/a%26gt;

%26lt;a href=%26quot;template.html%26quot;%26gt;

%26lt;img src=%26quot;../images/music.png%26quot; width=%26quot;100%26quot; /%26gt;%26lt;/a%26gt;

%26lt;/div%26gt;



This changes the z-index to 10, making it above the page (which is what I want), but *only* when I mouseover it, which makes no sense at all. Basically, I want it to have a z-index of 10 the entire time, not just when I mouseover it.



I can post more of the code if you deem it neccissary.CSS Z-Index Question?Z-index is a real pain at times. Actually I'm impressed you got it to work at all.



What I usually do is have a set background for the div, and if you need any images over top you can use normal absolute positioning.
CSS Z-Index Question?
200