Skip to content

Instantly share code, notes, and snippets.

@old-campos
Created March 11, 2013 21:34
Show Gist options
  • Save old-campos/5137986 to your computer and use it in GitHub Desktop.
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.
<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>
.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