How can I get the below snippet to look like this:
So that the items are evenly spaced, and the first item has no empty space on the left & the last item has no empty space on the right. Similar to what MS Word can do:
Full-justification
All lines in a paragraph are expanded so they are neat against both the left and right margins. To expand the line, space has to be added, between words and characters, to fill out the line.
In the code snippit below, there is lots of purple space to the left of the first item, I want to remove this.
ul {
list-style: none;
background-color: rebeccapurple;
color: white;
margin: 55px 10px;
display: flex;
// align-items: stretch;
justify-content: space-between;
}
li {
padding: 0;
background-color: #6495ed;
}
li:nth-of-type(2n) {
background: lightslategrey;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/dist/css/bootstrap.css" rel="stylesheet"/>
<ul class="nav navbar-nav">
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
UPDATE
@kukkuz answer below solves the snippit but I also had to add the below to get it to work with twitter Bootstrap. Bootstrap was adding :before
& :after
elements that were messing things up for me.
Removing them got it working for me, but I would recommend using a more specific selector that ul
otherwise you could mess things up with Bootstrap.
FYI - I was using Bootstrap from this CDN, v3.3.7: https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/dist/css/bootstrap.css
ul:before {
content: none;
}
ul:after {
content: none;
}