In the following snippet, you won't be able to see the first items of the flexbox.
Why ? How to solve this problem so the user can scroll horizontally to see all items ?
<div style="display: flex; justify-content: center; overflow: auto; padding: 30px 0">
<div style="padding: 0 15px">AAAAAA</div>
<div style="padding: 0 15px">BBBBBB</div>
<div style="padding: 0 15px">CCCCCC</div>
<div style="padding: 0 15px">DDDDDDD</div>
<div style="padding: 0 15px">EEEEEEE</div>
<div style="padding: 0 15px">FFFFFFF</div>
<div style="padding: 0 15px">GGGGGGG</div>
<div style="padding: 0 15px">HHHHHHH</div>
<div style="padding: 0 15px">iiiiiii</div>
<div style="padding: 0 15px">JJJJJJJ</div>
<div style="padding: 0 15px">KKKKKKK</div>
<div style="padding: 0 15px">LLLLLLL</div>
<div style="padding: 0 15px">MMMMMMM</div>
<div style="padding: 0 15px">OOOOOOO</div>
</div>
<div style="text-align: center">Scroll horizontally the letters above.</div>
Flex tries to fit every item in the same row. If you want to keep items centered add flex-wrap: wrap to the container. If you want to keep them in the same row though you have to changejustify-content to flex-start.
Here is the example of the flex-wrap solution.
<div style="display: flex; flex-wrap: wrap; justify-content: center; overflow: auto; padding: 30px 0">
<div style="padding: 0 15px">AAAAAA</div>
<div style="padding: 0 15px">BBBBBB</div>
<div style="padding: 0 15px">CCCCCC</div>
<div style="padding: 0 15px">DDDDDDD</div>
<div style="padding: 0 15px">EEEEEEE</div>
<div style="padding: 0 15px">FFFFFFF</div>
<div style="padding: 0 15px">GGGGGGG</div>
<div style="padding: 0 15px">HHHHHHH</div>
<div style="padding: 0 15px">iiiiiii</div>
<div style="padding: 0 15px">JJJJJJJ</div>
<div style="padding: 0 15px">KKKKKKK</div>
<div style="padding: 0 15px">LLLLLLL</div>
<div style="padding: 0 15px">MMMMMMM</div>
<div style="padding: 0 15px">OOOOOOO</div>
</div>
<div style="text-align: center">Scroll horizontally the letters above.</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With