Hongmu Notes
Home Language Notes css hamburger button
Language Notes CSS

css hamburger button

css hamburger button

Displays a hamburger menu that transforms into a cross button on hover.

Use a container with top, bottom and middle bars. .hamburger-menudiv
Set the container to with . display: flexflex-flow: column wrap
Use to add distance between bars. justify-content: space-between
Used to rotate the top and bottom bars 45 degrees and fade the middle bar on hover. transform: rotate()opacity: 0
Use to rotate the bar around the left point. transform-origin: left


<div class="hamburger-menu">
  <div class="bar top"></div>
  <div class="bar middle"></div>
  <div class="bar bottom"></div>
</div>

.hamburger-menu {
  display: flex;
  flex-flow: column wrap;
  justify-content: space-between;
  height: 2.5rem;
  width: 2.5rem;
  cursor: pointer;
}

.hamburger-menu .bar {
  height: 5px;
  background: black;
  border-radius: 5px;
  margin: 3px 0px;
  transform-origin: left;
  transition: all 0.5s;
}

.hamburger-menu:hover .top {
  transform: rotate(45deg);
}

.hamburger-menu:hover .middle {
  opacity: 0;
}

.hamburger-menu:hover .bottom {
  transform: rotate(-45deg);
}

 

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

css positioning

css positioning Language Notes CSS

Syntax: position: static | relative | absolute | fixed | center | page | sticky Default value: static Applies to: All elements except the display attribute defined as table-column-group | table-column Inheritance: No Animation: No...
👁 119
css vh and vw adaptive

css vh and vw adaptive Language Notes CSS

In the mobile terminal, REM is used to change the root HTML, and the mobile terminal adaptation is realized through a piece of JS. This article uses pure CSS viewport units to self-adapt. Although the current compatibility is not fully acceptable, it does not prevent you from recognizing the power of vw and vh. The implementation of responsive layout relies on media queries (Media Queries). Select the width size of mainstream devices as breakpoints to target...
👁 356

Recommended reading

Responsive Product Gift Box Packaging – Foreign Trade Enterprise Website Template 1107

Responsive Product Gift Box Packaging – Foreign Trade Enterprise Website Template 1107 Practical Collection Yiyou template

An Eyou CMS responsive website template designed for foreign trade enterprises specializing in product gift box packaging. Its premium, international design style effectively showcases gift box products, packaging designs, export advantages, and global market presence, helping packaging brands enhance their brand image in international markets. Template Demo | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for Eyou CMS | Eyou CMS (Ey...
👁 57
Responsive Metal Iron Hook Product Website Template for Foreign Trade Enterprises – 1108

Responsive Metal Iron Hook Product Website Template for Foreign Trade Enterprises – 1108 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for foreign trade enterprises specializing in metal hook products. Its professional, international design style effectively showcases metal products, technical specifications, export advantages, and global market presence, helping these enterprises strengthen their brand visibility in the international market. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (...
👁 35
Responsive Vehicle Tire Rim Website Template (Bilingual) 1109

Responsive Vehicle Tire Rim Website Template (Bilingual) 1109 Practical Collection Yiyou template

An eYouCMS responsive bilingual website template designed for the vehicle tire and wheel rim industry. Its professional, international design style effectively showcases tire and wheel rim products, technical specifications, export advantages, and brand identity. Multi-language support enables businesses to promote their brands across global markets. Template Demo | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for eYouCMS...
👁 56
Resource website typecho001 template

Resource website typecho001 template Program Notes Typecho

typecho001 template template please do not modify the folder name of this template. The folder name is: typecho001 1.4 Fix the js output problem on the article page 1.3 Fix the error prompt when the plug-in is not installed Optimize the list page code output 1.2 Fix the comment function and add a custom homepage title 1.1 Fix the comment reply asymmetry function Add a separate title setting function on the homepage Add the website favicon.ico icon Add one...
👁 198
Responsive Laser Cutting Machine Website Template (Bilingual) – 1110

Responsive Laser Cutting Machine Website Template (Bilingual) – 1110 Practical Collection Yiyou template

This EyouCMS responsive bilingual website template is ideal for the laser cutting machinery industry. Its modern, precision-oriented design effectively showcases laser cutting equipment products, technical specifications, competitive advantages, and project case studies. The multilingual support enables machinery manufacturers to promote their brands across global markets. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Common Installation Questions for EyouCMS...
👁 33
Modification of typecho paging style

Modification of typecho paging style Program Notes Typecho

Sir, times have changed! Typecho is currently the most perfect solution, because Baidu can only see the code of fixed thinking. The actual generated HTML code is breathtakingly clean and fully customized, including adding classes to the li element, adding classes to the a element, adding classes to the previous page and next page, and removing the li tags that come with typecho to express more. I can even add some text to the content inside...
👁 517