There are several ways to make navigation responsive, and usually the solution we need is quite straightforward. But despite the apparent simplicity, there are many underlying factors which, when thought through and implemented properly, can make a simple solution even better without adding more complexity to the user interface.
One of the problems I’ve encountered while building responsive navigations is that browsers currently don’t support CSS3 transitions to a height which is defined
auto. Most of the time, we shouldn’t use fixed height either because the height of menu items might not be the same in all browsers, and the number of items may change. I also always try to reduce the weight of pages I build, so I’ve been wanting a solution that doesn’t require a big library such as jQuery to work.
Further Reading on SmashingMag:
- Responsive Navigation On Complex Websites1
- Sticky Menus Are Quicker To Navigate2
- Progressive And Responsive Navigation3
height: 0 to
height: auto, which isn’t normally possible with CSS3 transitions.
- Simple, semantic markup.
- Weighs only 1.6 KB minified and Gzip’ed.
- Doesn’t require any external library.
- Uses CSS3 transitions and touch events.
- Removes the 300 ms delay between a physical tap and the click event.
- Makes it possible to use CSS3 transitions with
- Works in all major desktop and mobile browsers, including IE 6 and up.
- Free to use under the MIT license.
How It Works? Link
Responsive Nav is the successor of TinyNav.js10 which was released in 2011. While TinyNav worked so that it converted a regular navigation to a select menu, Responsive Nav only hides the original navigation and adds a toggle which opens and closes it. Responsive Nav doesn’t basically alter the html structure of the document at all, so it’s in that sense a much simpler solution.
Responsive Nav works by calculating in the background the max-height needed to fit all the menu items. When the user taps the navigation toggle the plugin uses CSS3 transitions to transition from a height that is set to 0 to the max-height it calculated earlier. Responsive Nav also attaches a
touchstart event listener to the toggle, which makes it possible to remove the default 300 ms delay that happens when using click events.
Why Choose This Over Another Solution? Link
Responsive Nav is lightweight and doesn’t depend on any external library. The navigation opens instantly on
Demo And Download Link
- Official website12, including instructions (works as a demo, too!)
- Live Demo13
- Download14 (ZIP archive includes seven examples)
- GitHub repository15
- 1 https://www.smashingmagazine.com/2013/09/responsive-navigation-on-complex-websites/
- 2 https://www.smashingmagazine.com/2012/09/sticky-menus-are-quicker-to-navigate/
- 3 https://www.smashingmagazine.com/2012/02/progressive-and-responsive-navigation/
- 4 http://responsive-nav.com
- 5 http://opensource.org/licenses/MIT
- 6 http://responsive-nav.com/
- 7 http://responsive-nav.com/
- 8 http://responsive-nav.com/demo
- 9 http://responsive-nav.com/demo
- 10 http://tinynav.viljamis.com/
- 11 https://github.com/viljamis/responsive-nav.js#tested-on-the-following-platforms
- 12 http://responsive-nav.com
- 13 http://responsive-nav.com/demo
- 14 https://github.com/viljamis/responsive-nav.js/archive/master.zip
- 15 https://github.com/viljamis/responsive-nav.js