I realize this question has been asked here and the highest upvoted answer was very helpful, however I am having an issue.
Basically I want a nav
(essential just a ul
and its li
s) to fill the width (or 80% of the width) equally.
The first task is to center the nav
the second task is to make sure that the items take up equal space. The other solution on SO proposes a bit of a hack, inserting content: ""
after the ul
. This works great, along with the other css rules I show below, when all li
s are one word. However, for two word li
s I get the effect achieved in my screen shot here:
If there is not a smooth way to remove that space, is there at least some sort of hack to make that space smaller that someone can think of?
I made a jsFiddle here but it doesn't really illustrate how bad the problem is.
Thanks a lot
HTML:
<article class="main home">
<img class="heroLogo" src="media/TM-Logo-4.png">
<nav>
<div class="menuIcon"></div>
<ul>
<li><a href="http://www.google.com">One</a></li>
<li><a href="http://www.google.com">One</a></li>
<li><a href="http://www.google.com">One</a></li>
<li><a href="http://www.google.com">Two longWords</a></li>
<li><a href="http://www.google.com">One</a></li>
<li><a href="http://www.google.com">One</a></li>
<li><a href="http://www.google.com">One</a></li>
</ul>
</nav>
</article>
CSS:
.menuIcon {
display: none;
}
nav, nav:hover {
width: 80%;
position: fixed;
left: 0;
right: 0;
bottom: 0;
margin: 0 auto;
font-size: 1.2em;
text-align: center;
}
nav ul, nav:hover ul, nav ul.clicked, nav ul.none {
width: 100%;
display: block;
text-align: center;
text-align: justify;
}
nav ul:after {
content: '';
display: inline-block;
width: 100%;
}
nav li {
width: 100%;
display: inline;
padding: 0;
margin: 0;
}