Hello,
as I mostly used horizontal menus, I'm just coming across this now:
How to have those menu items in a fixed width box and still make use of the hover feature?
I mean I want the background of the selected menu item to change it's background throughout the whole width of the surrounding menu box.
Below's my example. I tried to put padding around the text (so much that it overflows and that I used overflow hidden in the next higher div) and it worked, but then, the text isn't centered anymore!
I'd be really glad if someone could give me a hint on how to achieve what I want.
Cheers,
Dominique
menu.html
<html>
<head>
<title>menu test</title>
<link href="menu.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="menu">
<ul>
<li><a href="#"> home </a></li>
<li><a href="#"> vita </a></li>
<li><a href="#"> concerts </a></li>
<li><a href="#"> photos </a></li>
<li><a href="#"> extraits </a></li>
<li><a href="#"> presse </a></li>
<li><a href="#"> liens </a></li>
<li><a href="#"> contact </a></li>
</ul>
</div>
</body>
</html>
menu.css
body {
background: #333;
}
div#menu {
text-align: center;
float: right;
margin: 15px 15px 10px 10px;
}
ul { }
li {
text-align: center;
overflow: hidden;
width: 130px;
margin: 10px 0px;
list-style: none;
color: #fff;
border: 1px dotted #999;
}
li a {
text-decoration: none;
margin: 0px;
padding: 10px 60px;
color: #fff;
}
li a:hover {
background: #888;
}