Brief Tutorial
This is a cool hamburger deformation animation special effect made using jQuery and CSS3. This special effect attaches button events through jQuery and creates animation effects through CSS3 transform and animation.
How to use
HTML structure
The HTML structure of the hamburger deformation animation effect is as follows:
<div class='container'> <div class='burger'> <div class='burger__line-top'></div> <div class='burger__line-mid'></div> <div class='burger__menu'> <p>MENU</p> </div> </div> </div>
CSS style
Hamburger menu button The basic style is as follows:
.burger { position: absolute; left: 0; right: 0; top: 0; bottom: 0; margin: auto; width: 71px; height: 71px; cursor: pointer; } .burger__line-top { width: 100%; height: 8px; border-radius: 5px; background-color: #fff; box-shadow: 0 0 1px 0 #fff; } .burger__line-mid { margin-top: 17px; width: 100%; height: 8px; border-radius: 5px; background-color: #fff; box-shadow: 0 0 1px 0 #fff; } .burger__menu { margin-top: 10px; } .burger__menu p { text-align: center; font-size: 20px; font-family: 'Open Sans', sans-serif; font-weight: 900; color: #fff; text-shadow: 0 0 1px #fff; letter-spacing: 3px; }
Six animations are used in the style: activeTop, activeMid, activeMenu, reverseTop, reverseMid and reverseMenu. Used respectively to deform and return to the initial state of the hamburger button.
JavaScript
This special effect uses jQuery code to add and remove corresponding classes for corresponding elements, and bind mouse click events to the hamburger button.
'use strict'; $(document).ready(function () { var $burger = $('.burger'), $topLine = $('.burger__line-top'), $midLine = $('.burger__line-mid'), $menuLine = $('.burger__menu'), anim = false; var changeClasses = { addActive: function addActive() { for (var i = 0; i <= 2; i++) { $burger.children().eq(i).removeClass('reverseLine' + (i + 1)).addClass('activeLine' + (i + 1)); } }, addReverse: function addReverse() { for (var i = 0; i <= 2; i++) { $burger.children().eq(i).removeClass('activeLine' + (i + 1)).addClass('reverseLine' + (i + 1)); } } }; var timeouts = { initial: function initial(child, Y, rot, scale) { $burger.children().eq(child).css('transform', 'translateY(' + Y + 'px) rotate(' + rot + 'deg) scale(' + scale + ',1)'); }, afterActive: function afterActive() { var _this = this; // ES6 setTimeout(function () { _this.initial(0, 12, 45, 1.40); _this.initial(1, -12, -45, 1.40); _this.initial(2, 35, 0, 1); $burger.children().eq(2).css('opacity', '0'); anim = true; }, 1300); }, beforeReverse: function beforeReverse() { var _this2 = this; setTimeout(function () { for (var i = 0; i <= 2; i++) { _this2.initial(i, 0, 0, 1); } $burger.children().eq(2).css('opacity', '1'); anim = false; }, 1300); } }; $burger.on('click', function () { if (!anim) { changeClasses.addActive(); timeouts.afterActive(); } else if (anim) { changeClasses.addReverse(); timeouts.beforeReverse(); } }); });
The above is the content of the stunning hamburger deformation animation special effects of jQuery and CSS3. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Here's a container with some child elements:

Flyout menus! The second you need to implement a menu that uses a hover event to display more menu items, you're in tricky territory. For one, they should

"The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."- Tim Berners-Lee

In this week's roundup: datepickers are giving keyboard users headaches, a new web component compiler that helps fight FOUC, we finally get our hands on styling list item markers, and four steps to getting webmentions on your site.

The short answer: flex-shrink and flex-basis are probably what you’re lookin’ for.

In this week's look around the world of web platform news, Google Search Console makes it easier to view crawled markup, we learn that custom properties

The IndieWeb is a thing! They've got a conference coming up and everything. The New Yorker is even writing about it:


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment