I am using nav-pills as a collection of toggles for a tagging system. It is an unordered list with list elements. The list items are setup like this with Jade and NodeJS:
.row
.tagnav.col-xs-12
ul.ptag.nav.nav-pills
each tc in tagColours
li(onClick="selectTag('"+tc.tag+"', '"+tc.colour+"')").active #{tc.tag}
The row is aligned in the centre of the screen with:
.tagnav {
display: flex;
justify-content: center;
flex-direction: row;
}
like so:
As I make the window more narrow the nav-pills start to fold (which is good) but the layout is not pleasant. This is what they look like when I make the window smaller:
I would like them to line up nicely in centred rows. Like this (photoshopped):
I am using Jade for my HTML so I can get the tags dynamically from an array on the server so for the jsfiddle I’ve just put the tags in statically. They seem to behave the same. JSFiddle
Thanks.
2
Answers
Adding this makes it better:
Fiddle: https://jsfiddle.net/bnn9f3a3/
If you want to maintain the flex style..
(see fiddle below for a more readable comments explanation)
fiddle
based on your html structure
https://jsfiddle.net/Hastig/x3mu0k1d/
original, for others
https://jsfiddle.net/Hastig/h8w58rzd/