Reputation: 5009
Within my #header
#nav
, I have a <ul>
within an <li>
that displays on li:hover
. I want to put a border around everything but for some reason adding a border around the main <li>
makes the <ul>
within it fall out of alignment by one px on the left.
Here's a jsFiddle to show what I'm doing:
Here is my HTML:
<div id="header">
<div id="nav">
<ul>
<li id="thisli"><a href="#">Main Element</a>
<ul id="children">
<li><a href="#">First Child</a></li>
<li><a href="#">Second Child</a></li>
</ul>
</li>
</ul>
</div><!-- end nav -->
</div>
The border that throws it off is the border-left:1px solid #99B3FF
applied to li#thisli
. Can anyone help me figure out what's wrong?
Upvotes: 0
Views: 1907
Reputation: 816334
The inner ul
was always inside the li
. The border is something which is supposed to be around the content, so it is theoretically around the inner ul
as well. If you explicitly define the position of the inner ul
:
#nav li:hover ul {
display:block;
z-index:100;
left: 0px;
}
it is aligned: http://jsfiddle.net/Mh3Hg/4/
Upvotes: 1