RWD css3 menu with transition - andrew pougher
RWD css3 menu with transition - andrew pougher
by Andrew Pougher
HTML
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.0.2/css/font-awesome.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css">
<div id="page" class="container-fluid">
<div class="container">
<a href="#" class="open-panel"><i class="fa fa-align-justify fa-2x"></i></a>
<nav>
<ul class="menu">
<a href="#" class="close-panel"><i class="fa fa-times-circle fa-3x white"></i></a>
<li><a href="#">Home</a>
</li>
<li><a href="#">About</a>
</li>
<li><a href="#">Contacts</a>
</li>
</ul>
</nav>
</div>
<hr class="clearfix">
<div class="container">
<div class="row">
<div class="col-md-12 col-lg-12 col-xs-12">
<section>
<div id="content">
<h2>Page Title One</h2>
<div>bla bla bla </div>
</div>
</section>
<section>
<div id="content">
<h2>Page Title Two</h2>
<div>bla bla bla </div>
</div>
</section>
<section>
<div id="content">
<h2>Page Title Three</h2>
<div>bla bla bla </div>
</div>
</section>
<section>
<div id="content">
<h2>Page Title Four</h2>
<div>bla bla bla </div>
</div>
</section>
</div>
</div>
</div>
</div>
CSS
body {
font-family:arial;
background:#e8e8e8;
}
#page {
padding: 0em 1em 1em 1em;
}
ul {
height:80px;
background:#222222;
text-transform:uppercase;
font-size:11px;
letter-spacing:2px;
}
ul li {
display:inline;
margin-left:0px;
}
ul li a {
text-decoration:none;
border-radius:8px;
color:#fff;
line-height:70px;
padding:40px;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
}
ul li a:hover {
color:#000;
background:#a6cb4f;
}
a.open-panel, a.close-panel {
display: none;
}
#content{ clear: both; display: block;}
@media only screen and (max-width: 55em) {
nav {
width: 70%;
position: absolute;
left: -70%;
top: 0;
height: 100%;
background: #777;
}
ul.menu {
border-top: 1px solid #888;
}
ul{background:#222222;height:300px;width:100%}
ul li a {
color:white
line-height:70px;
padding:10px;
}
ul li a:hover {
color:#000;
background:#a6cb4f;
}
ul li {
float:left;
display:block;
width:100%;
height:40px;
margin-left:10px;
}
a.open-panel, a.close-panel {
display: inline;
color:white
}
.close-panel {
position: relative;
top: .5em;
left: 1em;
}
.openNav #page {
left: 0;
-webkit-transform: translate3d(70%, 0, 0);
-moz-transform: translate3d(70%, 0, 0);
-ms-transform: translate3d(70%, 0, 0);
-o-transform: translate3d(70%, 0, 0);
transform: translate3d(70%, 0, 0);
-webkit-transition: -webkit-transform 500ms ease;
-moz-transition: -moz-transform 500ms ease;
-o-transition: -o-transform 500ms ease;
transition: transform 500ms ease;
}
#page {
left: 0;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
...
JavaScript
$(".open-panel").click(function(){
$("html").addClass("openNav");
});
$(".close-panel, #content, nav a").click(function(){
$("html").removeClass("openNav");
});