Sweet Animated Menu Icon
How do I make an sweet animated menu icon?
I deconstructed Rokkan's slick implementation of the menu icon in a couple of slow-motion steps. It has two levels of transform animations going on at the same time which makes it feel super smooth.. What is a sweet animated menu icon? How do you make a sweet animated menu icon? This script and codes were developed by Olivia Cheng on 22 July 2022, Friday.
Sweet Animated Menu Icon - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Sweet Animated Menu Icon</title> <script src="http://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='http://codepen.io/heyitsolivia/pen/5d1c7d6c39ff3261a98ba0eab887a4f8.css'> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ .demo { margin: auto; padding: 75px 0 10px; width: 22px;
}
.description { margin: 35px auto; text-transform: uppercase; font-size: 10px; text-align: center; color: #999;
}
.menu { display: block; float: left; transition: all 275ms ease; cursor: pointer;
}
.menu span { display: block; width: 22px; height: 4px; background: #0088ce; margin-bottom: 2px; border-radius: 1px; transition: all 275ms ease;
}
.menu.active { transform: rotate(-45deg);
}
.menu.active .bar1 { transform: rotate(0deg) translateY(6px);
}
.menu.active .bar2 { opacity: 0;
}
.menu.active .bar3 { transform: rotate(-90deg) translateX(5px);
}
/* Deconstruction */
.demo.deconstruction { padding: 25px 0 10px;
}
.demo.deconstruction .menu,
.demo.deconstruction .menu span { transition: all 3s ease, background 275ms ease;
}
.demo.deconstruction .menu.step-1.active { transform: rotate(0deg);
}
.demo.deconstruction .menu.step-1.active span { background: #2da1dd;
}
.demo.deconstruction .menu.step-1.active .bar1 { transform: rotate(0deg) translateY(6px);
}
.demo.deconstruction .menu.step-1.active .bar2 { opacity: 0;
}
.demo.deconstruction .menu.step-1.active .bar3 { transform: rotate(-90deg) translateX(5px);
}
.demo.deconstruction .menu.step-2.active { transform: rotate(-45deg);
}
.demo.deconstruction .menu.step-2 span { background: #2da1dd;
}
.demo.deconstruction .menu.step-2 .bar1 { transform: rotate(0deg) translateY(6px);
}
.demo.deconstruction .menu.step-2 .bar2 { opacity: 0;
}
.demo.deconstruction .menu.step-2 .bar3 { transform: rotate(-90deg) translateX(5px);
}
.menu:hover span,
.menu.active span { background: #e74c3c !important;
}
hr { border: none; border-top: 1px dashed #ddd; margin: 50px 20px;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <header class='lite'> <h1>Animated Menu Icon</h1> <p> Deconstructing Rokkan's implementation at <a href="http://rokkan.com">rokkan.com</a> </p>
</header>
<div class='demo'> <div class='menu'> <span class='bar1'></span> <span class='bar2'></span> <span class='bar3'></span> </div>
</div>
<div class='description'>Normal</div>
<hr>
<div class='description'> <p> <strong>Click to deconstruct in Slow Motion</strong> </p>
</div>
<div class='demo deconstruction'> <div class='menu step-1'> <span class='bar1'></span> <span class='bar2'></span> <span class='bar3'></span> </div>
</div>
<div class='description'>Part 1</div>
<div class='demo deconstruction'> <div class='menu step-2'> <span class='bar1'></span> <span class='bar2'></span> <span class='bar3'></span> </div>
</div>
<div class='description'>Part 2</div>
<div class='demo deconstruction'> <div class='menu'> <span class='bar1'></span> <span class='bar2'></span> <span class='bar3'></span> </div>
</div>
<div class='description'>All together now</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Sweet Animated Menu Icon - Script Codes CSS Codes
.demo { margin: auto; padding: 75px 0 10px; width: 22px;
}
.description { margin: 35px auto; text-transform: uppercase; font-size: 10px; text-align: center; color: #999;
}
.menu { display: block; float: left; transition: all 275ms ease; cursor: pointer;
}
.menu span { display: block; width: 22px; height: 4px; background: #0088ce; margin-bottom: 2px; border-radius: 1px; transition: all 275ms ease;
}
.menu.active { transform: rotate(-45deg);
}
.menu.active .bar1 { transform: rotate(0deg) translateY(6px);
}
.menu.active .bar2 { opacity: 0;
}
.menu.active .bar3 { transform: rotate(-90deg) translateX(5px);
}
/* Deconstruction */
.demo.deconstruction { padding: 25px 0 10px;
}
.demo.deconstruction .menu,
.demo.deconstruction .menu span { transition: all 3s ease, background 275ms ease;
}
.demo.deconstruction .menu.step-1.active { transform: rotate(0deg);
}
.demo.deconstruction .menu.step-1.active span { background: #2da1dd;
}
.demo.deconstruction .menu.step-1.active .bar1 { transform: rotate(0deg) translateY(6px);
}
.demo.deconstruction .menu.step-1.active .bar2 { opacity: 0;
}
.demo.deconstruction .menu.step-1.active .bar3 { transform: rotate(-90deg) translateX(5px);
}
.demo.deconstruction .menu.step-2.active { transform: rotate(-45deg);
}
.demo.deconstruction .menu.step-2 span { background: #2da1dd;
}
.demo.deconstruction .menu.step-2 .bar1 { transform: rotate(0deg) translateY(6px);
}
.demo.deconstruction .menu.step-2 .bar2 { opacity: 0;
}
.demo.deconstruction .menu.step-2 .bar3 { transform: rotate(-90deg) translateX(5px);
}
.menu:hover span,
.menu.active span { background: #e74c3c !important;
}
hr { border: none; border-top: 1px dashed #ddd; margin: 50px 20px;
}
Sweet Animated Menu Icon - Script Codes JS Codes
$('.menu').click(function() { $(this).toggleClass('active');
});
Developer | Olivia Cheng |
Username | heyitsolivia |
Uploaded | July 22, 2022 |
Rating | 3.5 |
Size | 4,042 Kb |
Views | 42,504 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
A Pen by Olivia Cheng | 1,607 Kb |
Real-Time XKCD World Clock | 3,775 Kb |
CSS Clipping Path with CSS Shapes | 5,345 Kb |
Simple JS Fraction Parser | 3,475 Kb |
Svg by hand | 1,311 Kb |
Prototype Responsive Homepage | 7,677 Kb |
HTML5 markup for rodeo-003 | 3,075 Kb |
Using SVG filters with symbols | 2,125 Kb |
Nth type test | 1,880 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Social buttons | Flacu | 2,022 Kb |
Voting App - register | MatheusLima92 | 1,948 Kb |
3D Text in Sass | Bookcasey | 2,766 Kb |
A Pen by Shidhin | Shidhincr | 5,015 Kb |
ASCII triangle image overlay | Mitchdot | 2,200 Kb |
Custom checkbox example | Capelo | 3,495 Kb |
Single element checkbox | Ivijaygupta | 1,996 Kb |
Fading Navigation Bar | J-w-v | 2,805 Kb |
CSS Tooltips | Darylldoyle | 2,599 Kb |
Feedback Page | TessDiNapoli | 2,836 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!