gpt4 book ai didi

用于重复闪烁效果的 CSS 关键帧(wifi)

转载 作者:行者123 更新时间:2023-11-28 08:35:12 25 4
gpt4 key购买 nike

所以我正在尝试为元素创建 Wifi 闪烁效果。首先圆圈应该是可见的,然后是上面的圆圈,依此类推。在所有符号都可见后,它应该等待 2 秒,然后重新开始。你可以在这里看到我的当前状态:

http://jsfiddle.net/6jhgfdv0/

我用的css是

animation: blink 3s infinite;
animation-delay: 1s;

@keyframes blink {
0% {opacity: 0}
49%{opacity: 0}
50%{opacity: 1}
}

我想只改变延迟和其他值我可以让它看起来像那样,但它不起作用。我做错了什么?

body {
margin: 0;
padding: 0;
}

#body {
margin: 200px auto 0px;
width: 280px;
height: 84px;
background-color: #c9e3ed;
border-radius: 30px 30px 10px 10px / 20px 20px 10px 10px;
position: relative;
}

#wifi .signal {
border-right: 12px solid #ee7230;
border-bottom: 12px solid #ee7230;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
transform: rotate(-135deg);
position: absolute;
}

#wifi .signal:first-child {
left: 50%;
top: -160px;
margin-left: -56px;
width: 100px;
height: 100px;
border-radius: 0 0 100px 0;
animation: blink 3s infinite;
animation-delay: 1s;
}

#wifi .signal:nth-child(2) {
left: 50%;
top: -130px;
margin-left: -43px;
width: 74px;
height: 74px;
border-radius: 0 0 74px 0;
animation: blink 3s infinite;
animation-delay: 2s;
}

#wifi .signal:last-child {
left: 50%;
top: -100px;
margin-left: -30px;
width: 48px;
height: 48px;
border-radius: 0 0 48px 0;
animation: blink 3s infinite;
animation-delay: 3s;
}

#wifi .signal:last-child:after {
content: '';
position: absolute;
right: 35%;
bottom: 35%;
height: 30px;
width: 30px;
background-color: #ee7230;
border-radius: 50%;
margin-left: -25px;
animation: blink 3s infinite;
animation-delay: 4s;
}


@keyframes blink {
0% {opacity: 0}
49%{opacity: 0}
50%{opacity: 1}
}
<div id="router">
<div id="body">
<div id="wifi">
<div class="signal"></div>
<div class="signal"></div>
<div class="signal"></div>
</div>
</div>
</div>

最佳答案

创建多个动画,每个动画将以不同的百分比开始动画,然后您可以跳过动画延迟。

body {
margin: 0;
padding: 0;
}

#body {
margin: 200px auto 0px;
width: 280px;
height: 84px;
background-color: #c9e3ed;
border-radius: 30px 30px 10px 10px / 20px 20px 10px 10px;
position: relative;
}

#wifi .signal {
border-right: 12px solid #ee7230;
border-bottom: 12px solid #ee7230;
border-top: 1px solid #fff;
border-left: 1px solid #fff;
transform: rotate(-135deg);
position: absolute;
}

#wifi .signal:first-child {
left: 50%;
top: -160px;
margin-left: -56px;
width: 100px;
height: 100px;
border-radius: 0 0 100px 0;
animation: blink4 4s infinite;
}

#wifi .signal:nth-child(2) {
left: 50%;
top: -130px;
margin-left: -43px;
width: 74px;
height: 74px;
border-radius: 0 0 74px 0;
animation: blink3 4s infinite;
}

#wifi .signal:last-child {
left: 50%;
top: -100px;
margin-left: -30px;
width: 48px;
height: 48px;
border-radius: 0 0 48px 0;
animation: blink2 4s infinite;
}

#wifi .signal:last-child:after {
content: '';
position: absolute;
right: 35%;
bottom: 35%;
height: 30px;
width: 30px;
background-color: #ee7230;
border-radius: 50%;
margin-left: -25px;
animation: blink1 4s infinite;
}

@keyframes blink1 {
0% {
opacity: 0
}
19% {
opacity: 0
}
20% {
opacity: 1
}
}

@keyframes blink2 {
0% {
opacity: 0
}
39% {
opacity: 0
}
40% {
opacity: 1
}
}

@keyframes blink3 {
0% {
opacity: 0
}
59% {
opacity: 0
}
60% {
opacity: 1
}
}

@keyframes blink4 {
0% {
opacity: 0
}
79% {
opacity: 0
}
80% {
opacity: 1
}
}
<div id="router">
<div id="body">
<div id="wifi">
<div class="signal"></div>
<div class="signal"></div>
<div class="signal"></div>
</div>
</div>
</div>

关于用于重复闪烁效果的 CSS 关键帧(wifi),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53823186/

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