gpt4 book ai didi

html - 需要仅使用 CSS 下推 div

转载 作者:行者123 更新时间:2023-11-28 16:59:32 26 4
gpt4 key购买 nike

我有这段使用 jQuery 的代码,但我想知道仅使用 CSS 是否有可能实现相同的结果。这是我在 Codepen 上的代码:https://codepen.io/dj-smoke-starboy/pen/REOgvj。

我正在努力,但直到现在,我无法仅通过使用 css 来让它工作。

$('.card').each(function(i) {
$(this).fadeOut(1).delay(1000 * i).fadeIn(100)
});
body {
background-color: #ddd;
padding: 1em;
}

.cardWrap {
display: flex;
flex-direction: column-reverse;
}

.card {
background: #fff;
animation: slide 0.5s linear both;
margin-bottom: 1em;
opacity: 0;
padding: 5px;
transform: translateY(-5vh);
}

@keyframes slide {
0% {
filter: blur(1em);
opacity: 0;
}
100% {
filter: blur(0);
opacity: 1;
transform: translateY(0);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="cardWrap">
<div class="card">pushed DOWN</div>
<div class="card">10 - Itin</div>
<div class="card">9 - Itin</div>
<div class="card">8 - Itin</div>
<div class="card">7 - Itin</div>
<div class="card">6 - Itin</div>
<div class="card">5 - Itin</div>
<div class="card">4 - Itin</div>
<div class="card">3 - Itin</div>
<div class="card">2 - Itin</div>
<div class="card">1 - Itin</div>

</div>

通过使用 JS 和 jQuery 获得与我相同的结果。

最佳答案

我又做了:)

body {
background-color: #ddd;
padding: 1em;
}
.cardWrap {
display:flex;
flex-direction:column-reverse;
}
.card {
background:#fff;
animation: slide 0.5s linear both;
margin-bottom: 0;
opacity: 0;
padding:0;
height:0px;
width:0px;

}

.card:nth-child(1) {
animation: card1 .3s forwards .5s;
}

.card:nth-child(2) {
animation: card1 .3s forwards 1.5s;
}

.card:nth-child(3) {
animation: card1 .3s forwards 2.5s;
}

.card:nth-child(4) {
animation: card1 .3s forwards 3.5s;
}

.card:nth-child(5) {
animation: card1 .3s forwards 4.5s;
}

.card:nth-child(6) {
animation: card1 .3s forwards 5.5s;
}

.card:nth-child(7) {
animation: card1 .3s forwards 6.5s;
}

.card:nth-child(8) {
animation: card1 .3s forwards 7.5s;
}

.card:nth-child(9) {
animation: card1 .3s forwards 8.5s;
}

.card:nth-child(10) {
animation: card1 .3s forwards 9.5s;
}

.card:nth-child(11) {
animation: card1 .3s forwards 10.5s;
}


@keyframes card1{
to{opacity:1;height:auto;width:auto;padding:5px;margin-bottom: 1em;}
}
<div class="cardWrap">
<div class="card">pushed DOWN</div>
<div class="card">10 - Itin</div>
<div class="card">9 - Itin</div>
<div class="card">8 - Itin</div>
<div class="card">7 - Itin</div>
<div class="card">6 - Itin</div>
<div class="card">5 - Itin</div>
<div class="card">4 - Itin</div>
<div class="card">3 - Itin</div>
<div class="card">2 - Itin</div>
<div class="card">1 - Itin</div>
</div>

关于html - 需要仅使用 CSS 下推 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54223686/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com