aeropeek
03-03-2009, 04:58 PM
Hello all,
I am new to CSS and I'm trying to create a drop down menu (one level currently) with rounded corners without images.
Right now it's almost work in FF and Google Chrome except that the sub menu background width does not match text (width is fixed and not variable). In IE 7 there is a gap between menu items and width is the same as FF/GC.
Please take a look at the following code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Drop Down Menu</title>
<style type="text/css">
/* round corners */
.round {
background: transparent;
}
.content {
border-left:1px solid #9c9ea1;
border-right:1px solid #9c9ea1;
background:#eefa98;
padding: 0 1em;
}
.top, .bot {
font-size: 1px;
background: transparent;
display: block;
margin-top:0;
overflow: hidden;
}
.b1, .b2, .b3, .b4 {
display: block;
overflow: hidden;
background: transparent;
}
.b1, .b2, .b3 {
height: 1px;
}
.b2, .b3, .b4 {
background: #eefa98;
border-left: 1px solid #9c9ea1;
border-right: 1px solid #9c9ea1;
}
.b1 {
margin:0 5px;
background: #9c9ea1;
}
.b2 {
margin:0 3px;
border-width:0 2px;
}
.b3 {
margin:0 2px;
}
.b4 {
height:2px;
margin:0 1px;
}
/* Navigator */
#nav {
margin: 0;
list-style:none;
position: relative;
width: 18em;
}
#nav li {
float: left;
display: block;
position: relative;
text-decoration:none;
padding: 0;
margin: 0;
text-align:center;
width: 6em;
}
#nav li, #nav a {
text-decoration: none;
color: #af8d12;
}
#nav a:visited {
text-decoration: none;
}
#nav li:hover, #nav a:hover {
color: #5ea6ca;
}
#nav li ul.sub {
visibility: hidden;
list-style: none;
padding: 0;
text-align:left;
white-space:nowrap;
line-height: 22px;
}
#nav li:hover ul {
position: relative;
height:auto;
padding-top: 10px;
visibility: visible;
}
</style>
</head>
<body>
<ul id="nav">
<li><a href="index.php">Home</a></li>
<li><a href="#nogo">Products</a>
<div class="round">
<ul class="sub">
<li>
<b class="top"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b></b>
<div class="content">Product</div>
</li>
<li>
<div class="content">Longer Item 1234567890</div>
<b class="bot"><b class="b4"></b><b class="b3"></b><b class="b2"></b><b class="b1"></b></b> </li>
</ul>
</div>
</li>
<li><a href="#nogo">Services</a>
<div class="round">
<ul class="sub">
<li>
<b class="top"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b></b>
<div class="content">Service 1</div>
</li>
<li>
<div class="content">Service 2</div>
<b class="bot"><b class="b4"></b><b class="b3"></b><b class="b2"></b><b class="b1"></b></b> </li>
</ul>
</div>
</li>
</ul>
</body>
</html>
Thanks in advance,
Matan
I am new to CSS and I'm trying to create a drop down menu (one level currently) with rounded corners without images.
Right now it's almost work in FF and Google Chrome except that the sub menu background width does not match text (width is fixed and not variable). In IE 7 there is a gap between menu items and width is the same as FF/GC.
Please take a look at the following code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Drop Down Menu</title>
<style type="text/css">
/* round corners */
.round {
background: transparent;
}
.content {
border-left:1px solid #9c9ea1;
border-right:1px solid #9c9ea1;
background:#eefa98;
padding: 0 1em;
}
.top, .bot {
font-size: 1px;
background: transparent;
display: block;
margin-top:0;
overflow: hidden;
}
.b1, .b2, .b3, .b4 {
display: block;
overflow: hidden;
background: transparent;
}
.b1, .b2, .b3 {
height: 1px;
}
.b2, .b3, .b4 {
background: #eefa98;
border-left: 1px solid #9c9ea1;
border-right: 1px solid #9c9ea1;
}
.b1 {
margin:0 5px;
background: #9c9ea1;
}
.b2 {
margin:0 3px;
border-width:0 2px;
}
.b3 {
margin:0 2px;
}
.b4 {
height:2px;
margin:0 1px;
}
/* Navigator */
#nav {
margin: 0;
list-style:none;
position: relative;
width: 18em;
}
#nav li {
float: left;
display: block;
position: relative;
text-decoration:none;
padding: 0;
margin: 0;
text-align:center;
width: 6em;
}
#nav li, #nav a {
text-decoration: none;
color: #af8d12;
}
#nav a:visited {
text-decoration: none;
}
#nav li:hover, #nav a:hover {
color: #5ea6ca;
}
#nav li ul.sub {
visibility: hidden;
list-style: none;
padding: 0;
text-align:left;
white-space:nowrap;
line-height: 22px;
}
#nav li:hover ul {
position: relative;
height:auto;
padding-top: 10px;
visibility: visible;
}
</style>
</head>
<body>
<ul id="nav">
<li><a href="index.php">Home</a></li>
<li><a href="#nogo">Products</a>
<div class="round">
<ul class="sub">
<li>
<b class="top"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b></b>
<div class="content">Product</div>
</li>
<li>
<div class="content">Longer Item 1234567890</div>
<b class="bot"><b class="b4"></b><b class="b3"></b><b class="b2"></b><b class="b1"></b></b> </li>
</ul>
</div>
</li>
<li><a href="#nogo">Services</a>
<div class="round">
<ul class="sub">
<li>
<b class="top"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b></b>
<div class="content">Service 1</div>
</li>
<li>
<div class="content">Service 2</div>
<b class="bot"><b class="b4"></b><b class="b3"></b><b class="b2"></b><b class="b1"></b></b> </li>
</ul>
</div>
</li>
</ul>
</body>
</html>
Thanks in advance,
Matan