Byron Mh Byron Mh - 13 days ago 5
CSS Question

Locate div's in a specific order

if I have:

<div>A</div>
<div>B</div>
<div>C</div>


is there a way for the div's to appear this way when the page loads?

C
A
B


it doesnt matter the method

Answer

You can use display:flex and order to rearrange how the divs look on the dom

check this snippet

.container {
  display: flex;
  flex-direction: column;
}
div:nth-child(1) {
  order: 2;
}
div:nth-child(2) {
  order: 3;
}
div:nth-child(3) {
  order: 1;
}
<div class="container">

  <div>A</div>
  <div>B</div>
  <div>C</div>
</div>

Hope it helps