diff options
author | Bradley Taunt <bt@btxx.org> | 2024-05-25 16:14:03 -0400 |
---|---|---|
committer | Bradley Taunt <bt@btxx.org> | 2024-05-25 16:16:54 -0400 |
commit | e417a818e207a6cca6e2f3c471611673ab836a62 (patch) | |
tree | 664686a365c3d1e73349b5a667fa892f46445fef /_posts/2019-04-26-minimal-css-menu.md |
Initial commit for Jekyll testing and conversion, updated
Diffstat (limited to '_posts/2019-04-26-minimal-css-menu.md')
-rw-r--r-- | _posts/2019-04-26-minimal-css-menu.md | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/_posts/2019-04-26-minimal-css-menu.md b/_posts/2019-04-26-minimal-css-menu.md new file mode 100644 index 0000000..ec90cb4 --- /dev/null +++ b/_posts/2019-04-26-minimal-css-menu.md @@ -0,0 +1,58 @@ +--- +layout: post +title: "Minimal CSS: Dropdown Menu" +date: 2019-04-26 +--- + + +I love the idea of stripping away as much CSS as possible, while still maintaining the original UI concept. Let's build out a demo example with a simple menu dropdown element. + +Interesting facts about our final CSS menu: + +- Total weight 121 bytes minified! (not including any resets etc.) +- No complex HTML structures +- Accessibility support + +Now to see the final code in all it's glory: + +### HTML + + + <nav> + <ul> + <li><a href="">Home</a></li> + <li><a href="">About</a></li> + <li><a href="">Services</a> + <ul> + <li><a href="">Design</a></li> + <li><a href="">Development</a></li> + <li><a href="">Custom Pizzas</a></li> + </ul> + </li> + <li><a href="">Contact</a></li> + </ul> + </nav> + + +### CSS + + + /* resets - optional */ + ul { list-style: none; padding: 0; } + ul li { display: inline-block; position: relative; } + + /* minimal dropdown CSS */ + ul li > ul { + left: -9999px; + position: absolute; + visibility: hidden; + } + ul li:hover > ul, ul li:focus-within > ul { + left: 0; + visibility: visible; + } + + +## Live demo on CodePen + +Feel free to check out the live demo on CodePen [here](https://codepen.io/bradleytaunt/pen/MRLevy). |