Shadna
Shadna

Reputation: 65

How do I cover a portion of my border on my custom css menu

So here's the test site: http://rjewkes.com/index.php

If you roll over the menu items you'll see that the "li span" elements cut in front of the "li" elements. But I want it the other way around. I have them z-indexed appropriately but for some reason it doesn't work.

ul#topnav {
margin: 0 0 0 0; 
padding: 0;
float: left;
width: 1000px;
height:28px;
list-style: none;
position: relative;
background:url(images/navbar.jpg) no-repeat;
background-position:top left;
z-index:1000;
}
ul#topnav li {
float: left;
margin-top: 0; 
padding: 9px 0px 5px 0px;
z-index:1000;
}
ul#topnav li a {
float:left;
padding: 0 25px;
font-size:11px !important;
font-weight:bold;
display: block;
border:#transparent solid 1px;
color: #003654;
text-decoration: none;
z-index:1000;
}
ul#topnav li:hover {
background-color:#FFF;
position:static;
margin: -1px -1px 0 -1px !important;
padding-bottom:15px !important;
border-right: 1px solid #ccc;
border-top:#CCC solid 1px;
border-left:#CCC solid 1px;
z-index:1000;
}
ul#topnav li span {
float: left;
padding: 15px 0;
position: absolute;
left: 0; 
top:24px;
display: none;
width: 998px;
background-image:url(images/opacity.png);
color: #ccc;
z-index:1000;
}
ul#topnav li:hover span { 
display: block;
height:140px;
border: 1px solid #ccc;
margin-top:7px;
margin-left:-1px;
z-index:997;
-moz-box-shadow: 0px 8px 6px -6px rgba(0,0,0,0.1);
-webkit-box-shadow: 0px 8px 6px -6px rgba(0,0,0,0.1);
box-shadow: 0px 8px 6px -6px rgba(0,0,0,0.1);
/* For IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=180,     Color='#000000')";
/* For IE 5.5 - 7 */
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=180, Color='#000000');
}
ul#topnav li span a { 
background: transparent;
font-size:11px !important;
text-align:left;
border-left: 1px solid #ccc;
margin:5px 0 10px -1px;
padding:0 10px 0 20px;
width:100px;
height:130px;
display: inline;
z-index:997;
}
ul#topnav li span a:hover {
text-align:left;
color:#449ec7;
text-decoration: none;
z-index:997;
}
ul#topnav li span img {
position: relative;
float:right;
margin:10px 20px 0 0;
padding:0 0 0 0;
z-index:997;
}

I'd appreciate any feedback that helps solve this problem.

Upvotes: 0

Views: 122

Answers (1)

Aerendel
Aerendel

Reputation: 625

This is not a complete answer, but I can't use the comment functionality yet..

The z-index is not working here because only your <span> element is using position:absolute. No matter what z-index you give to your <li> element it won't matter because the <li> is not absolute positioned and thus bound to follow the DOM order.

Unfortunately I can't think of a simple way of doing this with your current markup. Absolute position the <li> elements would work, but that would be a mess and is not recommended at all if you want to keep the menu flexible. Any other solution I might think of would require radically changing the markup of the menu, or doing a small design change. This is unfortunately a very simple problem that has no simple solution.

I'll keep thinking about it, I might come up with an easy workaround.

Upvotes: 1

Related Questions