Skip to content

Instantly share code, notes, and snippets.

@Qtrain
Created March 29, 2015 22:29
Show Gist options
  • Save Qtrain/981abe7763712981f49c to your computer and use it in GitHub Desktop.
Save Qtrain/981abe7763712981f49c to your computer and use it in GitHub Desktop.
off canvas menu
<div class="wrapper">
<h1>Off Canvas Menu with Animated Links</h1>
<div class="mobile">
<!-- Checkbox to toggle the menu -->
<input type="checkbox" id="tm" />
<!-- The menu -->
<ul class="sidenav">
<li><a href="#"><i class="fa fa-check"></i><b>Tasks</b></a></li>
<li><a href="#"><i class="fa fa-inbox"></i><b>Messages</b></a></li>
<li><a href="#"><i class="fa fa-pencil"></i><b>New Post</b></a></li>
<li><a href="#"><i class="fa fa-cog"></i><b>Settings</b></a></li>
<li><a href="#"><i class="fa fa-star"></i><b>Starred</b></a></li>
<li><a href="#"><i class="fa fa-power-off"></i><b>Logout</b></a></li>
</ul>
<!-- Content area -->
<section>
<!-- Label for #tm checkbox -->
<label for="tm"><span>menu</span> <i class="fa fa-chevron-right"></i></label>
</section>
</div>
</div>
<span class="madewith">Made with <i class="fa fa-heart heart"></i> By <a href="http://mugfoundation.com">Matheus Silva</a></span>

off canvas menu

Leave a comment with suggestions or doubts. check-list

  • Mobile-friendly in progress
  • More details in progress

I have seen it on code player and transferred it to here to study it better to reproduce it but I made some small changes.


The MIT License (MIT)

Copyright (c) 2015 Matheus Xavier Silva

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

A Pen by Matheus Silva on CodePen.

License.

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-61157304-1', 'auto');
ga('send', 'pageview');
$darkPrimaryColor: #00796B;
$primaryColor: #009688;
$lightPrimaryColor: #B2DFDB;
$textPrimaryColor: #FFFFFF;
$accentColor: #536DFE;
$primaryTextColor: #212121;
$secondaryTextColor: #727272;
$dividerColor: #B6B6B6;
$barColor: #ffffff;
/*Fontawesome Iconfont*/
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css);
/*Montserrat, Open Sans*/
@import url( http://fonts.googleapis.com/css?family=Roboto:400,300);
* {margin: 0; padding: 0;}
html, body {
width: 100%;
height: 100%;
background: #333;
}
.wrapper {
width: 645px;
height: 500px;
margin: 35px auto 0 auto;
}
h1 {
color: white; font: 300 40px 'Roboto';
width: 300px; padding: 30px; float: left;
}
.mobile {
float: left;
position: relative;
box-shadow: 0 0 25px 0 rgba(0, 0, 0, 0.5);
overflow: hidden;
}
/*Hiding the checkbox*/
#tm {display: none;}
/*Content area*/
.mobile section {
background: url("http://assets.mugfoundation.com/images/textures/mb1.png");
background-color: #303F9F;
width: 285px;
height: 500px;
position: relative;
transition: all 0.25s;
}
.mobile section label {
outline: none;
color: white;
font: bold 14px Roboto;
text-align: center;
border: 2px solid white;
border-radius: 4px;
display: block;
padding: 10px 0;
width: 25%;
position: absolute;
left: 20%; top: 100px;
cursor: pointer;
text-transform: uppercase;
transition: all 0.4s ease;
}
/*Nav styles*/
.sidenav {
background: rgb(50, 60, 60);
width: 150px;
position: absolute;
left: 0;
top: 0;
bottom: 0;
padding-top: 100px;
}
.sidenav li {
list-style-type: none;
transition: all 1s;
}
.sidenav li:hover {
background: rgb(50, 60, 80);
}
.sidenav a { color: white; text-decoration: none; }
.sidenav b {
font: bold 12px/48px Roboto;
display: block;
opacity: 0;
transform: translateX(50px);
transition: all 0.4s;
}
.sidenav i {
display: block; width: 50px; float: left;
font-size: 16px; line-height: 48px; text-align: center;
}
/*Animation controls using checkbox hack*/
/*Animate content area to the right*/
section{
transform-origin: right;
}
#tm:checked ~ section {
transform: translateX(150px);
}
/*Animate links from right to left + fade in effect*/
#tm:checked ~ .sidenav b {
opacity: 1;
transform: translateX(0);
}
#tm:checked ~ section label {
width: 30%;
border-radius: 40%;
width: 10%;
span{
display: none;
}
}
#tm:checked ~ section label i{
margin-left: -10%;
transform: rotate(180deg);
}
/*Adding delay to link animation - in multiples of .08s*/
/*One can use jQuery also for creating the delayed effect. But I will stick to manual CSS for this walkthrough.*/
#tm:checked ~ .sidenav li:nth-child(1) b {transition-delay: 0.08s;}
#tm:checked ~ .sidenav li:nth-child(2) b {transition-delay: 0.16s;}
#tm:checked ~ .sidenav li:nth-child(3) b {transition-delay: 0.24s;}
#tm:checked ~ .sidenav li:nth-child(4) b {transition-delay: 0.32s;}
#tm:checked ~ .sidenav li:nth-child(5) b {transition-delay: 0.40s;}
#tm:checked ~ .sidenav li:nth-child(6) b {transition-delay: 0.48s;}
.madewith{
.heart{
color: salmon;
}
a{
color: $textPrimaryColor;
}
color: $secondaryTextColor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment