DEV Community

Cover image for How to build a responsive nav with no Javascript!
Devon Campbell
Devon Campbell

Posted on • Originally published at raddevon.com on

2

How to build a responsive nav with no Javascript!

In this video, I’ll teach you to build fancy collapsible navigation without using any Javascript. Just HTML and CSS!

I love that we can make clever use of CSS and HTML to achieve something most people use Javascript for, but you won’t get far as a web developer without Javascript. That’s why I made a cheat sheet with practical examples to help you learn it. Head over to this post's page on my site to get your copy.

If you want to work along with the video, start from this pen. Open that and click the “Fork” button in the bottom-right so you can get your own copy to work with.

The CSS framework I used is Milligram. I like to use it because it takes just basic HTML and makes it look nice. I don’t have to sprinkle a bunch of wacky classes around to get something that looks decent.

I talk about the “+” selector and refer to it in the video as the “sibling selector.” More accurately, it’s the adjacent sibling selector. It only selects the UL if it is a sibling of the checked checkbox and also if the two are adjacent (meaning no elements between).

Hope you enjoy this tutorial! Comment here or tweet at me if you have questions.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay