A div
of exact dimensions, measuring 800px wide and 50px tall, contains an unordered list of 6 elements that are centered within the div
. The alignment is currently working as intended.
My next goal is to create a dropdown list from each element. However, the second ul
is currently aligned to the left side of the container div
.
I am striving to center the dropdown list with each element while ensuring that the ul
elements have varying widths. Below is the progress I have made so far: jsFiddle. Any recommendations?
#bar {
width: 800px;
left: 50%;
transform: translate(-50%);
-webkit-transform: translate(-50%);
height: 50px;
background-color: lime;
position: absolute;
top: 20px;
}
.test-navbar ul {
width: 100%;
margin: 0 auto;
padding: 0;
list-style: none;
background-color: ;
text-align: center;
font-family: sans-serif;
}
.test-navbar li {
display: inline-block;
width: auto;
margin: 0;
padding: 0;
}
.test-navbar a {
text-align: center;
padding: 9px;
margin: 0;
display: block;
text-decoration: none;
color: #313131;
font-family: 'Oswald', sans-serif;
margin-top: 0px;
font-size: 23px;
background-color: ;
}
.test-navbar a:hover {
color: #f50057;
}
.test-navbar ul ul {
display: none;
position: absolute;
left: 0%;
background: #fff;
margin-left: 0px;
text-align: center;
width: 200px;
line-height: 40px;
padding: 10px;
}
.test-navbar ul ul li {
float: none;
width: 100%;
background-color: ;
}
.test-navbar ul ul a {
line-height: 0px;
padding: 5px 5px;
width: 100%;
background-color: ;
}
.test-navbar ul li:hover > ul {
display: block;
}
<div id="bar">
<div class="test-navbar">
<ul>
<li>
<a href="#">PASSION</a>
<ul>
<li><a href="">EXTRA FROM PASSION1</a></li>
<li><a href="">EXTRA FROM PASSION2</a></li>
<li><a href="">EXTRA FROM PASSION3</a></li>
<li><a href="">EXTRA FROM PASSION4</a></li>
<li><a href="">EXTRA FROM PASSION5</a></li>
<li><a href="">EXTRA FROM PASSION6</a></li>
</ul>
</li>
<li><a href="#">EXTRA AREA</a></li>
<li><a href="#">VIDEO</a></li>
<li>
<a href="#">ANOTHER LINK</a>
<ul>
<li><a href="">EXTRA FROM PASSION1</a></li>
<li><a href="">EXTRA FROM PASSION2</a></li>
<li><a href="">EXTRA FROM PASSION3</a></li>
<li><a href="">EXTRA FROM PASSION4</a></li>
<li><a href="">EXTRA FROM PASSION5</a></li>
<li><a href="">EXTRA FROM PASSION6</a></li>
</ul>
</li>
<li><a href="#">LINK5 STYLE</a></li>
<li><a href="#">BYE</a></li>
</ul>
</div>
</div>