Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ganshoot/6288192 to your computer and use it in GitHub Desktop.
Save ganshoot/6288192 to your computer and use it in GitHub Desktop.
A CodePen by Martin Wolf.
<h1>Centered fluid width navigation with floating links thanks to <code>fit-content</code></h1>
<nav class="nav" role="navigation">
<ul class="nav-list">
<li><a href="#">Home</a></li>
<li><a href="#">About me</a></li>
<li><a href="#">Clients</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</nav>
<p class="credits">Currently (April 2013) only supported in Chrome and Firefox.</p>
<p class="credits">Code by <a href="http://theamazingweb.net" target="_blank">Martin Wolf</a></p>
@import "compass";
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,600,700);
* {
margin: 0;
padding: 0;
@include box-sizing(border-box);
}
body {
padding: 3em 2em;
font-family: 'Open Sans', Arial, sans-serif;
font-size: 1em;
line-height: 1;
}
.clearfix {
&:after {
content: '';
display: table;
clear: both;
}
}
a {
color: #000;
text-decoration: none;
}
h1 {
margin: 0 auto 1.6em;
max-width: 600px;
font-size: 1.6em;
line-height: 1.2;
text-align: center;
}
code {
font-size: 1.5em;
color: #1da15b;
}
.nav {
max-width: 600px;
margin: 0 auto;
padding: 10px;
background: #fefefe;
border: 1px solid darken(#efefef, 5%);
}
.nav-list {
list-style: none;
margin: 0 auto;
width: -webkit-fit-content;
width: -moz-fit-content;
width: fit-content;
@extend .clearfix;
> li {
float: left;
&:last-child {
a {
margin-right: 0;
}
}
}
a {
display: block;
padding: 10px 12px;
margin: 0 1px 0 0;
color: #fff;
background: #18b160;
&:hover, &:focus {
background: lighten(#18b160, 7%);
}
}
}
/* Credits */
.credits {
padding: 3em 0 3em;
color: lighten(black, 50%);
font-size: 0.7em;
line-height: 1.7em;
text-align: center;
> a {
color: lighten(black, 50%);
text-decoration: none;
border-bottom: 1px solid lighten(black, 90%);
&:hover, &:focus {
border-bottom: 1px solid lighten(black, 70%);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment