samedi 14 mars 2020

Randomize the order of divs in a flexbox [duplicate]

I have a site that displays many creator in a flexbox (wich happens to be in a grid), and i was wondering how could i make the site shuffle the divs in a way that everytime the page is loaded i get a random sort. This is the simplified code:

HTML:

<div class="creators-wrapper">
   <div class="creator">John</div>
   <div class="creator">Michael</div>
   <div class="creator">David</div>
   <div class="creator">Kevin</div>
   <div class="creator">Sarah</div>
</div>

CSS:

.creators-wrapper {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
}

.creator {
  background: white;
  margin-bottom: 40px;
  width: 700px;
  height: 200px;
  border-radius: 20px;
}

Now, can i randomize the order of the creators' divs?




Aucun commentaire:

Enregistrer un commentaire