Skip to content

Instantly share code, notes, and snippets.

@iamtchelo
Created May 26, 2015 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamtchelo/3d2f0d1b134dfb103247 to your computer and use it in GitHub Desktop.
Save iamtchelo/3d2f0d1b134dfb103247 to your computer and use it in GitHub Desktop.
Responsive flex navigation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Flex Navigation with CSS3</title>
<style>
* {
margin: 0;
padding: 0;
}
.nav {
list-style: none;
padding: 10px 0;
display: flex;
flex-flow: row wrap;
background: tomato;
}
.nav a {
display: block;
padding: 1em;
color: #FFF;
text-decoration: none;
font-size: 14px;
font-family: Arial;
font-weight: bold;
}
.nav a:hover { background: rgba(0,0,0,0.1) }
@media only screen and (max-width: 800px) {
.nav { justify-content: space-around; }
}
@media only screen and (max-width: 600px) {
.nav {
flex-flow: column wrap;
}
.nav a {
text-align: center;
border-bottom: 1px solid rgba(0,0,0,0.1);
}
.nav li:last-child a {
border: none;
}
}
</style>
</head>
<body>
<ul class="nav">
<li class="nav-item"><a href="#">Home</a></li>
<li class="nav-item"><a href="#">About</a></li>
<li class="nav-item"><a href="#">Photos</a></li>
<li class="nav-item"><a href="#">Contact</a></li>
</ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment