Y
Y
Yura Yurievich2016-11-20 13:37:58
css
Yura Yurievich, 2016-11-20 13:37:58

How to align flexbox items like in the picture?

Good afternoon! I'm learning to use Flexbox, so I decided to make such a layout, and I can't figure out how to align the elements on the left side, as in the first picture. In fact, it fills all the empty space with space, and not giving an even indent and aligning it to the left side.
ff88347c819e45c8bd45506cdda5973c.png
Something like this structure:

<div>    //display: flex
    <ul>   //display: flex, justify-content: space-between; flex-wrap; wrap;
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</div>

But justify-content aligns like in the 2nd picture, but I would like it to be like in the 1st, is this possible? Thank you!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey delphinpro, 2016-11-20
@RealBoy2009

here is one solution https://jsfiddle.net/DelphinPRO/hm3ewt1d/
there is a second one, I wrote a fiddle here on a toaster, but I did not find it. In a nutshell: we do justify-content, add two pseudo-elements for the parent with a height of 1px and a width equal to the width of the rest of the blocks. order set for them more than for blocks.

A
A person from Kazakhstan, 2016-11-20
@LenovoId

codepen.io/Geyan/pen/yVgGWy?editors=110 right??

S
Sergey Goryachev, 2016-11-20
@webirus

Personally, in my opinion, this alignment looks prettier, and adapts much easier.
7c11882eb0d64538a3ba936d7b9a6d88.png5485ba3a85804a10a61ea7fbbf4ee2a1.png

X
xtala zen, 2016-11-20
@xtala

https://jsfiddle.net/3034a5bw/ everything else is trivial.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question