No JavaScript, No Hacks Hamburger Menu Interaction

DesignCourse · Beginner ·🌐 Frontend Engineering ·2y ago

Key Takeaways

The video demonstrates how to create an interactive hamburger menu using HTML and CSS without JavaScript, utilizing the new HTML popover feature.

Full Transcript

this right here is a very simple menu you click a hamburger icon and it opens up a navigation now the thing that makes this really cool is that there's no JavaScript no weird checkbox hacks it's entirely just HTML and CSS this here is the future of frontend development but you can't use it just yet as it's not supported in Firefox and there are accessibility issues however it's still intriguing to see how we'll become HTML programmers in the future if you enjoyed this video check out designc course.com where you can learn uiux CSS and more with my custom interactive platform that makes learning fun and easy all right so let's get started here I'm in a HTML file and of course this is where it all begins and we're going to wrap the uh hamburger menu and the menu in the navigation itself inside of a header element now next up we're going to have the button all right so this is the hamburger button and we're going to use a button element for this now this is real important this is the logic portion we want to put in an attribute that's specific to this use case called pop over Target and then we want to bind it to something called menu of course this could be any name that you wanted to give it now inside I'm just going to use an SVG graphic I'm going to paste in just the three you know kind of stylized design for hamburger menu nothing important happening here but this however you want to pay attention to so after the button we're going to have a nav and that's going to have a few attributes as well so we have to Define an attribute called popover letting us know that this is the actual pop over the thing that will pop up now we also want to put a rule attribute and bind it to menu and it will also give it an ID of menu as well all right menu menu menu so after that we're going to also have a close button so again we're going to use the button element and we can also use the popover Target menu as well so let's go ahead and just copy this stuff all right and then we're also going to put in popover Target action I know it's kind of a big mess I equals hide so hide and then I'm going to put in another SVG graphic for a close sort of button and then we're going to have an unordered list which is be our typical navigation structure home preferences my account support whatever and that's it I mean that's literally all we need to do just to fill out the page a little bit I will put a main with an H1 that says no JS menu reveal oopsie right there yeah all right perfect so now that we have that I we can go ahead right click open with live server and we'll see if this thing even works let's click it yeah it actually does work look at that so this is the default styling that's present I when you use this popover here in Chrome all right uh it you can see it's centered it has an outline we can override all the stuff and even apply transition animations with CSS so let's go ahead and focus on that so I'm going to paste in just some basic rule sets here nothing nothing exciting happening here um we're also going to go ahead and give our buttons styling here again nothing is crazy is happening here with respect to this new way of dealing with menus um now we're going to have a nav element okay so everything's going to be pretty much typical uh when with this rule set so you know as you can see I'm just using uh a width left bottom Auto you know we're just moving things around giving a different background color no border like that white border or that black border you saw height 100 viewport height we're just kind of getting the menu itself when it comes out styled all right so if I Sav this now when we go back and look at it I it should look like this all right look look at that okay so we're getting somewhere now what we want to do is I want to specify a translate property 100% on the x axis so when we do this and I go back we can't see it because we've moved it out of the way it's off it's off to the right out of the browser you can't even see it now we also want to apply if we wanted to have a transition um when it comes back we also want to apply a transition property but what's what let's wait for that part um let's actually get it showing up again and the way we can get it styled back to 100 or to to zero on the x-axis is simply we're going to say an pop over hyphen open and we say translate 0 0 all right now let's save this and see what happens at this point so we click it all right so it's basically the exact same behavior that we had before I but it doesn't look like it's different because we're not actually animating it at all so to do that we want to put it in a transition so our transition property here is going to be translate 0.5 seconds and then also display 0.5 seconds ease out and allow hyphen discret so if you don't specify this this will basically not work it won't work correctly we also need to specify in at roll starting hyphen style and we simply take this value right here and paste it in here so it's kind of defining and it's it's letting this new system know that translate is 100% on the xais axis rather when you know uh in its default state or starting state so if we save this and we go back look at that so now we have a nice transition and it works exactly as you expect except without any JavaScript um we'll find on a final note just because this looks so ugly I am going to paste in just a few more rule sets right here again it's not really pertinent to the purpose of this tutorial but I'm just going to go ahead and do it because I'm a designer I'm a little bit I can't leave the tutorial looking like that so if I click this there we go much better you could add some hover interactions if you wish but this is exactly how it works so our Clos button works this button works it opens it up we can also use the ES Escape key and we could also just click anywhere on the outside of it so all this functionality is built in to the system in the browser simply using HTML in CSS which is freaking awesome of course you can't use this right now or you shouldn't rather uh because there are accessibility issues like I mentioned at the beginning of the video and obviously Firefox this doesn't yet exist but anyhow it's fun to look at the how things will be done in the future so that we can worry less about having to program stuffff with JavaScript all right everybody if you enjoyed this make sure to subscribe and I will see you all very soon goodbye

Original Description

https://bit.ly/410u02U 👈 Design & code like me. Use "BF2023" for 50% Off! https://designcourse.com/af 👈 My upcoming "Advanced Frontends" Course -- Today, I'm going to show you an entirely new way to create interactive menu reveals with the new HTML popover. Caution: You cannot use this in production yet, as it's not supported in Firefox and does have accessibility issues. However, it's always intriguing to see how we'll be handling these common interactions in the future! 0:00 - Intro 0:33 - HTML 3:05 - CSS Let's get started! #frontend #css #html - - - - - - - - - - - - - - - - - - - - - - Subscribe for NEW VIDEOS! Learn UI/UX: https://designcourse.com My personal FB account: http://fb.com/logodesigner Coursetro FB: http://fb.com/coursetro Coursetro's Twitter: http://twitter.com/designcoursecom Join my Discord! https://discord.gg/a27CKAF ^-Chat with me and others - - - - - - - - - - - - - - - - - - - - - - Who is Gary Simon? Well, I'm a full stack developer with 2+ decades experience and I teach people how to design and code. I've created around 100+ courses for big brands like LinkedIn, Lynda.com, Pluralsight and Envato Network. Now, I focus all of my time and energy on this channel and my website Designcourse.com. Come to my discord server or add me on social media and say Hi!
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from DesignCourse · DesignCourse · 0 of 60

← Previous Next →
1 Photoshop Pen Tool Tutorial (Tattoo Design)
Photoshop Pen Tool Tutorial (Tattoo Design)
DesignCourse
2 How to Design the Microsoft Logo in Photoshop
How to Design the Microsoft Logo in Photoshop
DesignCourse
3 Photoshop Gradients Video Tutorial
Photoshop Gradients Video Tutorial
DesignCourse
4 Your Guide to Layer Styles
Your Guide to Layer Styles
DesignCourse
5 Layer Masks in Photoshop
Layer Masks in Photoshop
DesignCourse
6 iOS App Icon Design Tutorial in Illustrator CS6
iOS App Icon Design Tutorial in Illustrator CS6
DesignCourse
7 Illustrator CS6 Logo Design Tutorial - Archfold
Illustrator CS6 Logo Design Tutorial - Archfold
DesignCourse
8 Photoshop CS6 3D Tutorial - Magic Tent Illustration
Photoshop CS6 3D Tutorial - Magic Tent Illustration
DesignCourse
9 How to Design a Tshirt Tutorial - Adobe Illustrator
How to Design a Tshirt Tutorial - Adobe Illustrator
DesignCourse
10 Types of Logos - Lettermark & Monogram Logo Type
Types of Logos - Lettermark & Monogram Logo Type
DesignCourse
11 Banner Design in Photoshop CS6
Banner Design in Photoshop CS6
DesignCourse
12 How to Design a Logo in Illustrator CC
How to Design a Logo in Illustrator CC
DesignCourse
13 Designing a Logo in Photoshop CC
Designing a Logo in Photoshop CC
DesignCourse
14 1. Launch & Market a Web Based Business - Introduction
1. Launch & Market a Web Based Business - Introduction
DesignCourse
15 2. Launch & Market a Web Based Business - Logo Design
2. Launch & Market a Web Based Business - Logo Design
DesignCourse
16 3. Home Page Mockup in PS : Part 1
3. Home Page Mockup in PS : Part 1
DesignCourse
17 4. Home Page Mockup in PS : Part 2
4. Home Page Mockup in PS : Part 2
DesignCourse
18 5. Home Page Mockup in PS : Part 3
5. Home Page Mockup in PS : Part 3
DesignCourse
19 6. Home Page Mockup in PS : Part 4
6. Home Page Mockup in PS : Part 4
DesignCourse
20 7. Home Page HTML & CSS - Part 1
7. Home Page HTML & CSS - Part 1
DesignCourse
21 8. Home Page HTML & CSS - Part 2
8. Home Page HTML & CSS - Part 2
DesignCourse
22 Using Photoshop to Showcase Mobile Projects
Using Photoshop to Showcase Mobile Projects
DesignCourse
23 Flat Icon Design Tutorial in Illustrator CC
Flat Icon Design Tutorial in Illustrator CC
DesignCourse
24 Illustrator CC Logo Design Tutorial - A Logo That "Pops"!
Illustrator CC Logo Design Tutorial - A Logo That "Pops"!
DesignCourse
25 Logo Design Follow Along 1: Emblem Logo Design
Logo Design Follow Along 1: Emblem Logo Design
DesignCourse
26 Showcasing Logos in 3D with Blender
Showcasing Logos in 3D with Blender
DesignCourse
27 How to Design an Effective Lettermark Logo
How to Design an Effective Lettermark Logo
DesignCourse
28 Squeeze Page Design Tutorial in Photoshop (Part 1)
Squeeze Page Design Tutorial in Photoshop (Part 1)
DesignCourse
29 Squeeze Page Design Tutorial in Photoshop (Part 2)
Squeeze Page Design Tutorial in Photoshop (Part 2)
DesignCourse
30 Mobile GUI Element Design in Adobe Photoshop CC (Part 1)
Mobile GUI Element Design in Adobe Photoshop CC (Part 1)
DesignCourse
31 Mobile GUI Element Design in Adobe Photoshop CC (Part 2)
Mobile GUI Element Design in Adobe Photoshop CC (Part 2)
DesignCourse
32 Flat Mobile App Design in Photoshop CC - Weather App
Flat Mobile App Design in Photoshop CC - Weather App
DesignCourse
33 Create Reflective 3D Text in Blender (Beginner)
Create Reflective 3D Text in Blender (Beginner)
DesignCourse
34 Animating a Logo with Adobe After Effects CC (Beginner)
Animating a Logo with Adobe After Effects CC (Beginner)
DesignCourse
35 Design a Game Website Mockup in Photoshop CC (Part 1)
Design a Game Website Mockup in Photoshop CC (Part 1)
DesignCourse
36 Design a Game Website Mockup in Photoshop CC (Part 2)
Design a Game Website Mockup in Photoshop CC (Part 2)
DesignCourse
37 Photo Manipulation Tutorial in Photoshop CC (Beginner)
Photo Manipulation Tutorial in Photoshop CC (Beginner)
DesignCourse
38 Advertising Illustration Tutorial in Photoshop CC
Advertising Illustration Tutorial in Photoshop CC
DesignCourse
39 Perspective Warp Tool Tutorial in Photoshop CC
Perspective Warp Tool Tutorial in Photoshop CC
DesignCourse
40 Free Giveaway Contest.  (WiseBanner Banner Maker).
Free Giveaway Contest. (WiseBanner Banner Maker).
DesignCourse
41 Design an Animated Loading/Download Icon (GIF)
Design an Animated Loading/Download Icon (GIF)
DesignCourse
42 Contest Winners (WiseBanner)
Contest Winners (WiseBanner)
DesignCourse
43 Model & Animate a 3D Push Button in Blender (Beginner)
Model & Animate a 3D Push Button in Blender (Beginner)
DesignCourse
44 Mega Tutorial - iPhone Breathalyzer - Project Introduction
Mega Tutorial - iPhone Breathalyzer - Project Introduction
DesignCourse
45 Part 1 - iPhone Breathalyzer - Blender
Part 1 - iPhone Breathalyzer - Blender
DesignCourse
46 Part 2 - iPhone Breathalyzer - Rendering & GUI Design
Part 2 - iPhone Breathalyzer - Rendering & GUI Design
DesignCourse
47 Part 3 - iPhone Breathalyzer - UI Animation in After Effects
Part 3 - iPhone Breathalyzer - UI Animation in After Effects
DesignCourse
48 Part 4 - iPhone Breathalyzer - Website Design in Photoshop CC
Part 4 - iPhone Breathalyzer - Website Design in Photoshop CC
DesignCourse
49 Part 5 - iPhone Breathalyzer - HTML Part 1
Part 5 - iPhone Breathalyzer - HTML Part 1
DesignCourse
50 Part 6 - iPhone Breathalyzer - HTML/CSS Part 2
Part 6 - iPhone Breathalyzer - HTML/CSS Part 2
DesignCourse
51 Part 7 - iPhone Breathalyzer - HTML/CSS Part 3
Part 7 - iPhone Breathalyzer - HTML/CSS Part 3
DesignCourse
52 Part 7 - iPhone Breathalyzer - Finishing Touches
Part 7 - iPhone Breathalyzer - Finishing Touches
DesignCourse
53 Square Space Logo Maker - C'mon People.
Square Space Logo Maker - C'mon People.
DesignCourse
54 Design a Bloody Knife in Photoshop CC
Design a Bloody Knife in Photoshop CC
DesignCourse
55 Typographic Poster Design Tutorial in Illustrator (Part 1)
Typographic Poster Design Tutorial in Illustrator (Part 1)
DesignCourse
56 Typographic Poster Design Tutorial in Illustrator (Part 2)
Typographic Poster Design Tutorial in Illustrator (Part 2)
DesignCourse
57 Modern Business Card Design in Illustrator CC (Part 1)
Modern Business Card Design in Illustrator CC (Part 1)
DesignCourse
58 Modern Business Card Design in Illustrator CC (Part 2)
Modern Business Card Design in Illustrator CC (Part 2)
DesignCourse
59 Parallax Tutorial using Parallax.JS
Parallax Tutorial using Parallax.JS
DesignCourse
60 Interview: Andrew Price of BlenderGuru.com
Interview: Andrew Price of BlenderGuru.com
DesignCourse

Create an interactive hamburger menu using HTML and CSS without JavaScript, and learn how to style it with CSS transitions.

Key Takeaways
  1. Create a header element with a button and nav elements
  2. Add popover target and popover attributes to the button and nav elements
  3. Style the menu with CSS transitions and translations
  4. Add a close button and unordered list to the nav element
  5. Test the menu with a live server
💡 The HTML popover feature allows for interactive menus without JavaScript, but has accessibility issues and limited browser support.

Related Reads

📰
The Enter key that submits your form while a Japanese user is still typing
Learn how to prevent the Enter key from submitting a form while a Japanese user is still typing, and why it matters for user experience
Dev.to · greymoth
📰
The two-Reacts bug: when packages aren't singletons
Learn to fix the two-Reacts bug by understanding how to handle non-singleton packages in React applications
Dev.to · r9v
📰
🚀 Introducing Prism Guard — An Open Source Frontend Architecture Intelligence Platform
Learn about Prism Guard, an open-source frontend architecture intelligence platform, and how it can help improve codebase quality
Dev.to · Ritumoni Sarma
📰
The Death of the Heavy Hydration Layer
Learn why plain HTML is the new developer flex and how to simplify web development by ditching heavy hydration layers
Dev.to · Amodit Jha

Chapters (3)

Intro
0:33 HTML
3:05 CSS
Up next
The masks we wear | Zora Krstić | TEDxLuxembourgCity
TEDx Talks
Watch →