initializr-template icon indicating copy to clipboard operation
initializr-template copied to clipboard

Navigation menu wraps when adding new menu items

Open SamWM opened this issue 13 years ago • 10 comments

If I have 4 or more menu items in the navigations, the menu items can wrap onto the next line. I take width off nav and nav aand it makes no difference. Would be more useful if the menu was more scalable (at least half a dozen menu items should be able to show without wrapping)

SamWM avatar Jan 08 '12 18:01 SamWM

Same problem here.

ghost avatar Jan 10 '12 12:01 ghost

Same problem...

sotte avatar Jan 17 '12 11:01 sotte

+1

lukashoffmann avatar Jan 18 '12 09:01 lukashoffmann

Okay so to sum up:

  • The nav width is 38% compared to the global width of the page,
  • Each anchor width in the nav is approximately 30%, so 3 * 30% is still < 100% for 3 elements.

If you want to add more items, you have to adapt their width so they don't exceed 100% (take margins and paddings into account). Like put 20% for 4 elements, or 45% for 2 for instance.

If you add more than 3 items or if the content of your items is long, it might wrap because the nav is limited by its 38% width. In that case just increase the nav width so it matches your needs. The nav's 38% width limitation is here to keep the design consistent and aligned with the aside bar which has the same width, but you can put whatever you want instead if you don't care about this alignment.

To make it scalable, we would have to use a CSS preprocessor like LESS or SASS to calculate the number of elements and adapt the percentages depending on this, which is a little bit overkill compared to just calculate it manually once :)

If you have alternative solutions, please don't hesitate to share them!

verekia avatar Jan 24 '12 00:01 verekia

Possible workaround: #header-container { height:150px; } #header-container header { position: relative; height: 100%;} #header-container nav { width: 400px; position: absolute; right: 0; bottom: 0; }

SamWM avatar Jan 26 '12 16:01 SamWM

Hi Sam, Unfortunately, having any hard-coded pixel value (like your width: 400px) breaks the responsiveness of the template, it would be too easy otherwise :)

verekia avatar Jan 27 '12 17:01 verekia

Verekia: I just tried Sam's solution and it seems to work perfectly. Can you explain why it breaks the responsiveness because it seems to solve the issue completely?

WhatFreshHellIsThis avatar Jan 30 '12 19:01 WhatFreshHellIsThis

If you put the width under @media only screen and (min-width: 768px) then that solves the responsiveness. Lower resolution screens will just see the navigation in list format.

To cater for Internet Explorer

.oldie #header-container { height: 150px; }

.oldie #header-container header { position: relative; height: 100%; }

.oldie #title { font-size: 68px; }

.oldie #header-container nav { width: 400px; position: absolute; right: 0; bottom: 0; }

SamWM avatar Feb 01 '12 09:02 SamWM

Hi, I'm very new to this and cant seem to work out how to get another 2 navigational links in the header without the li wrapping. Also can you still produce responsive drop down menus with this?

webfeetdesign avatar Nov 20 '12 11:11 webfeetdesign

Hi @verekia, i have 6 tabs, i'm trying with nav width: 16%; or any other value and i only got 2 columns with 3 tabs in each one. What could be the problem? thanks (The @SamWM solution didn't work too)

IngCazzaro avatar Jan 13 '15 15:01 IngCazzaro