I have a drop down menu where I want some of the list items to be in one line.
See demo
You will notice that under Tab One
, there are 9 rows. I want there to be three rows with three items in each row. How can this be done in 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;
}
Working example: http://jsfiddle.net/w7a3N/5/
Remove >
from #menu > li {
and set inner <li>
to <li style="width: 33%;">
Not sure if the style="width:33%;"
is absolutely necessary since it works in Firefox 20 without it, but just to be safe.
UPDATE
You asked for a version that only does multiple columns under the first tab. Here you go:
http://jsfiddle.net/w7a3N/6/
Gave First tab an id like so <ul id="tab1"
and then added this to CSS:
#tab1 li{
display: block;
position: relative;
float: left;
width: 33%;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With