


Detailed explanation of the css3 transition animation of menu bar 'three' transforming into 'X'
I recently wanted to imitate a page. One of the effects is that the three menu bars are transformed into X.
The effect is as follows:
Picture (1) Initial effect
Picture (2) Mouse hover effect
Idea:
The implementation of three horizontal lines: Traditionally, it can be achieved with three span tags, but there is a more clever method. One tag can achieve the three horizontal effect. According to Master Zhang Xinxu shared the idea of using padding to achieve the effect of three with one label. The general principle is to use border-top, background and border-bottom for the upper, middle and lower horizontal lines respectively. Use background-clip: content-box to cut, and finally use padding to spread it up and down to achieve the visual effect of three horizontal lines, the realization of
X: and the deformed X There is no need for additional labels, and it is implemented using its own after before pseudo-class transform rotation and offset. It takes patience to adjust the angle.
It should be noted that using padding to achieve the three-horizontal effect, the trigger is not very sensitive. It is best to wrap the icon label with a label, and do: hover trigger on the wrapping layer
The following is the code
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Document</title> <style type="text/css"> .icon{ width: 50px; height: 10px; padding: 10px 0; border-top: 10px solid #000; border-bottom: 10px solid #000; background: #000; background-clip: content-box; } .fa{ cursor: pointer; width: 50px; height: 50px; transition: .3s ease; } .fa:hover>.icon{ border: 0; background: none; } .icon:before,.icon:after{ position: absolute; content: ""; width: 60px; height: 60px; transition: .3s ease; -webkit-transition: .3s ease; opacity: 0; } .icon:before{ top: -5px; border-bottom: 10px solid #000; } .icon:after{ top: 15px; border-top: 10px solid #000; } .fa:hover>.icon:before{ opacity: 1; transform: rotate(135deg) translateX(5px) translateY(-25px); -webkit-transform: rotate(135deg) translateX(5px) translateY(-25px); } .fa:hover>.icon:after{ opacity: 1; transform: rotate(-135deg) translateX(20px) translateY(39px); -webkit-transform: rotate(-135deg) translateX(20px) translateY(39px); } </style> </head> <body> <p class="fa"> <p class="icon"></p> </p> <script type="text/javascript"> </script> </body> </html>
More menu bar "three" transforms into "X" css3 transition animation for detailed explanation. Please pay attention to the PHP Chinese website for related articles!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics











I see Google Fonts rolled out a new design (Tweet). Compared to the last big redesign, this feels much more iterative. I can barely tell the difference

Have you ever needed a countdown timer on a project? For something like that, it might be natural to reach for a plugin, but it’s actually a lot more

Everything you ever wanted to know about data attributes in HTML, CSS, and JavaScript.

At the start of a new project, Sass compilation happens in the blink of an eye. This feels great, especially when it’s paired with Browsersync, which reloads

Tartan is a patterned cloth that’s typically associated with Scotland, particularly their fashionable kilts. On tartanify.com, we gathered over 5,000 tartan

The inline-template directive allows us to build rich Vue components as a progressive enhancement over existing WordPress markup.

PHP templating often gets a bad rap for facilitating subpar code — but that doesn't have to be the case. Let’s look at how PHP projects can enforce a basic

We are always looking to make the web more accessible. Color contrast is just math, so Sass can help cover edge cases that designers might have missed.
