我有一个下拉菜单,我希望一些列表项在一行中。
看演示
您会注意到在 下Tab One
,有 9 行。我希望有三行,每行有三个项目。如何在 CSS 中做到这一点?
HTML:
<div id="wrapper">
<ul id="menu">
<li><a href="#">Tab One</a>
<ul style="width: 300%;">
<li><a href="#">Column one</a></li>
<li><a href="#">Column one</a></li>
<li><a href="#">Column one</a></li>
<li><a href="#">Column two</a></li>
<li><a href="#">Column two</a></li>
<li><a href="#">Column two</a></li>
<li><a href="#">Column three</a></li>
<li><a href="#">Column three</a></li>
<li><a href="#">Column three</a></li>
</ul>
</li>
<li><a href="#">Tab Two</a>
<ul style="position: relative; left: -100%; width: 300%">
<li><a href="#">Tab 2</a></li>
<li><a href="#">Tab 2</a></li>
<li><a href="#">Tab 2</a></li>
</ul>
</li>
<li><a href="#">Tab Three</a>
<ul style="position: relative; left: -200%; width: 300%">
<li><a href="#">Tab 3</a></li>
<li><a href="#">Tab 3</a></li>
<li><a href="#">Tab 3</a></li>
</ul>
</li>
</ul>
</div>
CSS:
body {
font-family: arial;
margin: 0px;
padding-left: 40px;
padding-right: 40px;
}
#wrapper {
text-align: center;
height: auto;
margin: auto;
min-width: 500px;
}
#wrap {
display: inline;
}
ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}
#menu > li {
display: block;
position: relative;
float: left;
width: 33.3%;
}
li ul {
display: none;
}
ul li a {
display: block;
text-decoration: none;
color: #ffffff;
border-top: 1px solid #ffffff;
padding: 5px 15px 5px 15px;
background: #1e7c9a;
margin-left: 1px;
white-space: nowrap;
}
ul li a:hover {
background: #3b3b3b;
}
li:hover ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
font-size: 14px;
}
li:hover a {
background: #3b3b3b;
}
li:hover li a:hover {
background-color: black;
opacity: .7;
}