Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

CSS3 animations - menu icon

Featured Replies

Hi guys,


Im working on a personal project at the moment and what I want to achieve is an effect such as the one seen at pollenlondon.com, however with a twist; on hover I want the menu icon to spin (as seen on pollen) into a Z shape, then on click (I have found a tutorial with this however it uses SASS and I can't seem to transfer it to normal css) turn into an X exactly as the pollen animation does...



I know this is achievable with css (as I have seen it in the tutorial (keyframes) however I have only used preset animations (transitions.css) and never made my own before. If anyone could share any insight on how to do this or even contribute some code I would be an extremely happy bunny...


Thanks in advance,


Alex


I think I have an idea what you mean. I did something similar on a project I fron-ended reacently. You'll have to resize the screen to get the navbar to collapse and show the menu icon.

http://wasabiadmin.se/fonstermastaren-backend/

 

This is how I built it:

 

HTML

<div class="site-header__toggle-nav" id="toggleSiteNav">
   <span class="burger burger-top"></span>
   <span class="burger burger-middle"></span>
   <span class="burger burger-bottom"></span>
</div>

CSS

.burger {
  position: relative;
  display: block;
  width: 20px;
  height: 3px;
  background: #151515;
  margin: 0 auto 3px;
  text-indent: -60px;
  transition: -webkit-transform 0.3s, opacity 0.3s;
  transition: transform 0.3s, opacity 0.3s;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.site-header__nav-open .burger__middle {
   opacity: 0;
}
.site-header__nav-open .burger__top {
   top: 6px;
}
.site-header__nav-open .burger__top,
.site-header__nav-open .burger__middle {
   -webkit-transform: rotate(45deg);
   -ms-transform: rotate(45deg);
   transform: rotate(45deg);
}
.site-header__nav-open .burger__bottom {
   top: -6px;
   -webkit-transform: rotate(-45deg);
   -ms-transform: rotate(-45deg);
   transform: rotate(-45deg);
}

 

You require javascript to initiate the toggle event that adds the class of site-header__nav-open to the navigation parent that the nav toggle also resides in. You can get more info using the chrome dev tools on the like I provided for you above.

 

If you haven't already I highly recommend you learn sass once your css skills are upto scratch, once you're using it you'll never want to code in vanilla css again, it's such a timesaver.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.