Answers for "flexbox limit items per column"

4

flexbox limit items per row

<style>
  .parent {
    display: flex;
    flex-wrap: wrap;
  }

  .child {
    /* percent per item in row. 
    33% = limit to 3 per row. */
    flex: 1 0 33%; 
    margin: 5px;
    height: 100px;
    background-color: blue;
  }
</style>

<div class="parent">
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
  <div class="child"></div>
</div>
Posted by: Guest on December-31-2020
0

use flex in container with multiple components

.wrap {
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;         /* NEW */
  height: 100px;                  /* NEW */
  justify-content: space-between; /* NEW */
}
.elem1 {
  width: 20%;
  flex-basis: 100%;               /* NEW */
  border: 1px solid red;
}
.elem2,
.elem3 {
  width: 75%;
  flex-basis: 40%;                /* NEW */
  border: 1px solid red;
}
Posted by: Guest on August-21-2020

Code answers related to "flexbox limit items per column"

Browse Popular Code Answers by Language