Menu Fixed Responsive
by DanielSTh
HTML
<link href='http://fonts.googleapis.com/css?family=Abel' rel='stylesheet' type='text/css'/>
<header class="header-fixed">
<div class="header-limiter">
<h1><a href="#">Tu<span>Logo</span></a></h1>
<nav>
<a href="#" class="selected">Inicio</a>
<a href="#">Acerca</a>
<a href="#">Tutoriales</a>
<a href="#">Contactos</a>
<a href="#">SiteMap</a>
</nav>
</div>
</header>
CSS
body{background-color: #EFF3FA;}
.header-fixed {
background-color: #fff;
border-bottom: 1px solid #c2c9d4;
padding: 20px 40px;
height: 80px;
color: #444;
box-sizing: border-box;
top:-100px;
-webkit-transition:top 0.3s;
transition:top 0.3s;
}
.header-fixed .header-limiter {
max-width: 1200px;
text-align: center;
margin: 0 auto;
}
.header-fixed-placeholder{
height: 80px;
display: none;
}
/* Logo */
.header-fixed .header-limiter h1 {
float: left;
font: bold 30px 'Abel', sans-serif;
line-height: 40px;
margin: 0;
}
.header-fixed .header-limiter h1 span {
color: #00BFBC;
}
/* Enlaces de la navegacion */
.header-fixed .header-limiter a {
color: #FD5159;
text-decoration: none;
}
.header-fixed .header-limiter nav {
font: 18px 'Abel', sans-serif;
line-height: 40px;
float: right;
}
.header-fixed .header-limiter nav a{
display: inline-block;
padding: 0 5px;
text-decoration:none;
color: #444;
opacity: 0.9;
}
.header-fixed .header-limiter nav a:hover{
opacity: 1;
}
.header-fixed .header-limiter nav a.selected {
color: #00BFBC;
pointer-events: none;
opacity: 1;
}
/* Versión fija del encabezado */
body.fixed .header-fixed {
padding: 10px 40px;
height: 50px;
position: fixed;
width: 100%;
top: 0;
left: 0;
z-index: 1;
}
body.fixed .header-fixed-placeholder {
display: block;
}
body.fixed .header-fixed .header-limiter h1 {
font-size: 24px;
line-height: 30px;
}
body.fixed .header-fixed .header-limiter nav {
line-height: 28px;
font-size: 13px;
}
/* Responsive */
@media all and (max-width: 600px) {
.header-fixed {
padding: 20px 0;
height: 75px;
}
.header-fixed .header-limiter h1 {
float: none;
margin: -8px 0 10px;
text-align: center;
font-size: 24px;
line-height: 1;
}
.header-fixed .header-limiter nav {
line-height: 1;
float:none;
}
.header-fixed .header-limiter nav a {
font-size: 13px;
}
body.fixed .header-fixed {
display: none;
}
}
/*
Nos estamos limpiando el cuerpo margen y el...
JavaScript
$(document).ready(function(){
var showHeaderAt = 150;
var win = $(window),
body = $('body');
// Mostrar el encabezado fijo sólo en dispositivos con pantalla más grande.
if(win.width() > 600){
// Aparece cuando bajas más de 150px.
win.on('scroll', function(e){
if(win.scrollTop() > showHeaderAt) {
body.addClass('fixed');
}
else {
body.removeClass('fixed');
}
});
}
});