Created
March 11, 2013 21:34
-
-
Save old-campos/5137986 to your computer and use it in GitHub Desktop.
A CodePen by Francisco Campos. .css file .center ul uses a: fit-content to horizontally center a floated navgiation on a page.
This file contains 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
<div class="navbar center"> | |
<ul> | |
<li><a href="/">Home</a></li> | |
<li><a href="/">About Us</a></li> | |
<li><a href="/">Our Products</a></li> | |
<li><a href="/">Customer Suppot</a></li> | |
<li><a href="/">Contact</a></li> |
This file contains 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
.center ul { | |
width: -moz-fit-content; | |
width: -webkit-fit-content; | |
width: fit-content; | |
margin: auto; | |
} | |
.navbar ul li{ | |
float: left; | |
padding: 5px; | |
} | |
.navbar li a { | |
text-decoration: none; | |
color: #262728; | |
font: 400 18px/1.4 "Century Gothic", Helvetica, sans-serif; | |
transition: 0.1s; /*applies transition to the underline hover as well*/ | |
} | |
.navbar a:hover { | |
color: red; | |
border-bottom: 3px solid red; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment