-
-
Save cfxd/6119486 to your computer and use it in GitHub Desktop.
Tableless horizontal navigation bar with padding and even spacing; no space between elements, no unused container space, and no fixed width (so works for any number of elements!).Fiddle at http://jsfiddle.net/VBcUM/2/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Using display: table-cell to evenly determine widths. You can add an arbitrary number of <li> | |
*/ | |
ul { | |
padding: 0; | |
display: table; | |
width: 100%; | |
table-layout: fixed; | |
} | |
li { | |
display: table-cell; | |
} | |
a { | |
display: block; | |
padding: 1em; | |
text-align: center; | |
background: white; | |
} | |
a:hover { | |
background: lime; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<li><a href="#">Lorem ipsum</a></li> | |
<li><a href="#">Dolor</a></li> | |
<li><a href="#">Sit</a></li> | |
<li><a href="#">Amet</a></li> | |
<li><a href="#">Consectetur</a></li> | |
<li><a href="#">Adipiscing</a></li> | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ul { | |
padding: 0; | |
display: table; | |
width: 100%; | |
table-layout: fixed; | |
li { | |
display: table-cell; | |
a { | |
display: block; | |
padding: 1em; | |
text-align: center; | |
background: white; | |
&:hover { | |
background: lime; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment