I’m trying to create a horizontal menu using CSS. It has to be fixed width because the ‘buttons’ tie into an image below.
I have created the menu and it works, however, the hover and clickable areas seem to be a bit strange in IE8. Rather than the whole button being clickable, the top and bottom is and the text is, but the rest is not??
See attached image, I have highlighted the areas in yellow that act as a link or initiate teh hover effect - I want to avoid those dead areas either side of the text.
Hi, you have given us the CSS, although not the HTML to go along with that code. If IE8 is displaying that way, is Opera/FF also dispalying it like this? Or just IE8. If just IE8 make sure your HTML/CSS is valid.
Post a link to yoru site so we can fully debug this :). Or if you don’t have a site, post your HTML to go along wit that (try and minimalize the test case so it’s easier for us and quicker)
Give the parent float position:relative to bring it on top.
#header-buttons ul {
list-style:none;
padding:0px;
margin:0px;
float:left;
[B] position:relative;
z-index:9;[/B]/* at least higher than what comes next*/
}
Seemed to be a bit of a bug in IE8 and the following content that wrapped the float seem to lay on top of everything except the foreground anchor text.
I just forced the issue and made the floated buttons be higher in the stacking context and the wrapping content went underneath as it should.
IE8 has always had link bugs right from the start and in the beta version you had to add position:relative to make links active. This is probably a similar bug.
Reduced text case:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
ul {
list-style:none;
margin:0;
padding:0;
}
li, li a {
float:right;
width:100px;
text-align:center;
color:#000;
background:red;
height:25px;
line-height:25px;
display:inline;
text-decoration:none
}
li {
margin:0 10px;
}
li a:hover {
background:blue;
color:yellow
}
div {
}
</style>
</head>
<body>
<ul>
<li><a href="#">test link</a></li>
<li><a href="#">test link</a></li>
<li><a href="#">test link</a></li>
<li><a href="#">test link</a></li>
</ul>
<div><a href="#">b</a></div>
</div>
<p>An empty div containing an anchor results that in the floated menu the space to the side of the text is not clickable or active and the top and bottom are a bit hit and miss also. The text is ok. Giving a width or height to the div solves the problem as does setting position:relative on the floated menu.</p>
</body>
</html>