Skip to content

Instantly share code, notes, and snippets.

View iansvo's full-sized avatar

Ian Svoboda iansvo

View GitHub Profile
@iansvo
iansvo / Nav-Equalizer-Demo.markdown
Created February 15, 2015 15:03
Nav Equalizer Demo

Nav Equalizer Demo

The below navigation will automatically size itself according to the length/content of the links added to it. The demo below demonstrates the effect when using variable amounts of links and/or variable link text length.

The trick is to use a display table/table-cell properties on the menu and it's list items respectively. This insures that the browser handles the menu items correctly and doesn't rely on awkward margin-calulations, especially with variable amounts of menu items.

Go ahead and try adding/removing menu items to see the effect. You can also adjust your browser window to see how it performs in a responsive scenario or with variable browser widths.

A Pen by Ian Svoboda on CodePen.