需要divs下推

编程入门 行业动态 更新时间:2024-10-14 12:23:53
本文介绍了需要divs下推的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

插入新的div时,需要将div下推.我在 codepen 中有此代码.

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

现在,div依次插入,但随后需要推动.

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="cdnjs.cloudflare/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>

推荐答案

我是用display:flex和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="code.jquery/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>

更多推荐

需要divs下推

本文发布于:2023-11-07 00:32:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565068.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:divs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!