我已经成功创建此导航菜单,但菜单项的间距已关闭。同样在次要名单上,由于其中一项,我不得不让它们变宽。有没有办法让宽度根据最长项目的长度而变化。CSS下拉菜单间距
Menu
body {
font-family: "Gill Sans", Calibri, "Trebuchet MS", sans-serif;
}
#nav, #nav ul { /* all lists */
padding: 0;
margin: 0;
list-style: none;
line-height: 1;
}
#nav a {
display: block;
width: 10em;
}
#nav li { /* all list items */
/* The sum of the next two lines creates the nav bar height*/
padding-top:12px;
height: 28px;
float: left;
background: #f15a22;
width: 7em; /* width needed or else Opera goes nuts */
}
#nav li ul { /* second-level lists */
position: absolute;
background: #f15a22;
width: 10em; /* controls width of background colour of second-level list - currently set to width of lon