0

How can one create the vertically "equi-distant" item alignment apparent in "uneven" grid like layouts (for example https://www.zergnet.com/)?

I tried CSS flex layout to do the same, and all I get is:

enter image description here

My code is something like this (simplified version), and the screenshot above was taken when the viewport was set to 320px width:

My goal is to create a layout where all the buttons on the right of the image above have the same vertical space between them as the buttons on the left. The design also needs to be fully responsive.

<div style="display:flex;justify-content:flex-start;align-items:flex-start;flex-wrap:wrap;">
    <button>Lorem ipsum</button>
    <button>Lorem ipsum gypsum</button>
    <button>Lorem ipsum</button>
    <button>Lorem ipsum gypsum</button>
    <button>Lorem ipsum</button>
</div>
TylerH
  • 20,799
  • 66
  • 75
  • 101
Hassan Baig
  • 15,055
  • 27
  • 102
  • 205

1 Answers1

0

If you mean something like this, you are looking for flex-direction: column and justify-content: flex-start; that are flexbox properties.

You can read more about it here.

<div class="wrapper">
        <button>1</button>
        <button>2</button>
        <button>3</button>
        <button>4</button>
        <button>5</button>
        <button>6</button>
        <button>7</button>
        <button>8</button>
    </div>
<style>
    .wrapper {
            width: 300px; height: 270px;
            border: 1px solid blue;
            display:flex;
            align-items:flex-start;
            flex-wrap:wrap;
            flex-direction: column;
            justify-content: flex-start;
    }
    .wrapper button {  width: 70px; height: 50px; margin: 6px;}
    .wrapper button:nth-child(2),
    .wrapper button:nth-child(4),
    .wrapper button:nth-child(6) {  height: 80px; }
</style>
TylerH
  • 20,799
  • 66
  • 75
  • 101
Nico Diz
  • 1,484
  • 1
  • 7
  • 20