space-between
will work- check out the example below:
body { margin: 0; } * { box-sizing: border-box; } .wrapper { display: flex; justify-content: space-between; } .wrapper > * { border: 1px solid; }
<div class="wrapper"> <div>one</div> <div>two</div> <div>three</div> <div>four</div> <div>five</div> </div>
Another way is using auto
margins for the items at the end- but it has a different effect- see demo below:
body { margin: 0; } * { box-sizing: border-box; } .wrapper { display: flex; justify-content: space-around; } .wrapper > * { border: 1px solid; } .wrapper div:first-child { margin-right: auto; } .wrapper div:last-child { margin-left: auto; }
<div class="wrapper"> <div>one</div> <div>two</div> <div>three</div> <div>four</div> <div>five</div> </div>
With flexbox you could use the justify-content property to define the item's distribution behavior.
justify-content: space-around;
is what you need is what you need.
Here is a example: http://codepen.io/fazermokeur/pen/WGJpJO
(directly inspired by this perfect resource about flexbox: https://css-tricks.com/snippets/css/a-guide-to-flexbox/ )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.