Sweet Animated Menu Icon

Developer
Size
4,042 Kb
Views
42,504

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 Previews

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');
});
Sweet Animated Menu Icon - Script Codes
Sweet Animated Menu Icon - Script Codes
Home Page Home
Developer Olivia Cheng
Username heyitsolivia
Uploaded July 22, 2022
Rating 3.5
Size 4,042 Kb
Views 42,504
Do you need developer help for Sweet Animated Menu Icon?

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!

Olivia Cheng (heyitsolivia) Script Codes
Create amazing marketing copy with AI!

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!