Need divs to be push down

Viewed 119

Need divs to be pushed down when new div is inserted. I have this code in codepen.

Right now the divs are inserted one after another, but I need then to be pushed.

$('.dashdiv').each(function(i) {
  $(this).fadeOut(1).delay(1000 * i).fadeIn(1850);
});
.dashdiv {
  background: grey;
  margin: 5px;
  width: 200px;
  color: #fff;
  padding: 10px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="dashdiv">1 - One</div>
<div class="dashdiv">2 - Two</div>
<div class="dashdiv">3 - Three</div>
<div class="dashdiv">4 - Four</div>
<div class="dashdiv">5 - Five</div>
<div class="dashdiv">Need push DOWN</div>

1 Answers

I made with display:flex and flex-direction:column-reverse

$('.dashdiv').each(function(i) {
  $(this).fadeOut(1).delay(1000*(i)).fadeIn(1850);
});
.dashdiv { background:grey; margin:5px; width:200px; color:#fff; padding: 10px;}

.flex {
  display:flex;
  flex-direction:column-reverse;
}
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>

<div class="flex">
  <div class="dashdiv">1 - One</div>
  <div class="dashdiv">2 - Two</div>
  <div class="dashdiv">3 - Three</div>
  <div class="dashdiv">4 - Four</div>
  <div class="dashdiv">5 - Five</div>
  <div class="dashdiv">Need push DOWN</div>
</div>

Related