Reputation: 405
I've a problem with a website I'm building. I've a menu containing 2 links (called "Default" and "Test") into list items but in Firefox I can't click them. In IE they works: I think is a z-index problem of items on the page but I can't solve it.
<!DOCTYPE html>
<html>
<head>
<style>
.sezup li.current{
color:#067d2c;
position:relative;
z-index:20;
}
.sezup a, a:hover{
color:#067d2c;
position:relative;
z-index:20;
}
.header{
position:relative;
top:0px;
}
.sezup {
margin: 0 auto;
padding: 0 0 0 75px;
width:800px;
position:relative;
z-index:20;
}
#lineaup {
background: url("../Images/sfondobarraup.png") repeat scroll 0 0 transparent;
height: 16px;
margin: 55px 0 0;
position: relative;
z-index: 0;
top: -25px;
left: 0px;
}
#lineaup li {
bottom: 6px;
float: left;
margin: 0 10px;
padding: 2px 15px;
position: relative;
}
.loghi {
margin: 0 auto;
padding: 20px 0 0;
position: relative;
top: -45px;
width: 1000px;
height: 97px;
border:1px black solid;
}
#logo {
position: relative;
top: -20px;
float:left;
}
#calciatore {
position: relative;
float:right;
top:-50px;
}
#erba {
background: url("../Images/erba.png") repeat scroll 0 0 transparent;
height: 65px;
position: relative;
top: -110px;
z-index: 0;
border:1px black solid;
}
</style>
</head>
<body>
<div class="header">
<div id="lineaup">
<div class="sezup">
<ul>
<li class="current"><a href="Default.aspx" id="hrefHome">Default</a></li>
<li><a href="test.aspx?id=1" id="hrefProfile">Test</a></li>
</ul>
</div>
</div>
<div class="loghi">
<img src="" title="logo" id="logo" /><img src="" title="logo" id="calciatore" />
</div>
<div id="erba">
</div>
</div>
</body>
</html>
Upvotes: 3
Views: 7007
Reputation: 12869
Get rid of all z-index
except for:
#lineaup {
z-index: 1;
}
and
#erba {
z-index: -1;
}
You should only change the z-index
of the parent elements. There's no reason to assign the children elements with higher and higher indices
.
Also, since it's usually just one element behind another, this -1
and 1
solution not only works but looks nice, and is easy to understand, I think.
For the record, negative z-indices are allowed.
Upvotes: 1
Reputation: 18024
Because of the stacking context, once you set a z-index on a parent element, you can't "break out" of it by setting a higher z-index on a child element.
Usually it's a lot easier to deal with by removing all the superfluous z-index values and only adding them where you need it.
Upvotes: 3
Reputation: 2263
Increase the z-index for #lineap
#lineaup {
z-index: 1;
...
}
http://jsfiddle.net/willemvb/wxWBm/
Upvotes: 0