Skip to content

Instantly share code, notes, and snippets.

@vincentntang
Created October 26, 2018 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincentntang/1829c22fde08cc7bc66ee100a0c3f2d7 to your computer and use it in GitHub Desktop.
Save vincentntang/1829c22fde08cc7bc66ee100a0c3f2d7 to your computer and use it in GitHub Desktop.
Simple Pure CSS Mega Menu
.nav-wrapper
.nav
each val in [1, 2, 3, 4, "Good Bye"]
.dropdown
a Category
.megamenu
p= val
p Hello World

Simple Pure CSS Mega Menu

Hover over each category to see a unique mega menu for each category tab. No javascript. Uses as few CSS classes / declarations as possible to be succint.

Uses jade (preprocessed HTML) and regular CSS. View the compiled HTML (top right corner) to see what it would like in just HTML.

Intenationally not responsive. Just use something like bootstrap container instead of nav-wrapper. Read more about other responsive examples I made here

https://vincentmtang.com/2018/10/25/make-css-mega-menu/

A Pen by Vincent Tang on CodePen.

License.

.nav-wrapper {
width: 600px;
font-size: 23px;
}
.nav {
display: flex;
background-color: lightgray;
justify-content: space-between;
position: relative; /* so megamenu spans entire nav*/
}
.dropdown {
width: 100%;
border-right: 1px solid black;
}
.dropdown:last-of-type {
border-right: none;
}
a {
text-align: center;
display: block;
}
/* Set megamenu controls */
.megamenu {
position: absolute; /* relative position on nav*/
left: 0;
width: 100%;
visibility: hidden;
display: block;
background-color: lightblue;
text-align: center;
}
.dropdown:hover .megamenu {
visibility: visible;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment