gpt4 book ai didi

css - 如何实现扫描条动画?

转载 作者:行者123 更新时间:2023-12-03 21:06:22 24 4
gpt4 key购买 nike

如何添加连接到移动垂直线的绿色阴影效果。
有关我的目标的示例,请参见图像。
如何在 CSS 中实现它?
enter image description here
这是我实现的示例

body {
height: 100vh;
position: relative;
}

.ocrloader p::before {
content: '';
display:inline-block;
width: 12px;
height: 12px;
border-radius: 50%;
background: #18c89b;
position: relative;
right: 4px;
}
.ocrloader p {
color: #18c89b;
position: absolute;
bottom: -30px;
left: 38%;
font-size: 16px;
font-weight: 600;
animation: blinker 1.5s linear infinite;
font-family: sans-serif;
text-transform: uppercase;
}

.ocrloader {
width: 360px;
height: 225px;
position: absolute;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
top: 40%;
backface-visibility: hidden;
}

.ocrloader span {
position: absolute;
left: 35px;
top: 0;
width: 85%;
height: 5px;
background-color: #18c89b;
box-shadow: 0 0 10px 1px #18c89b,
0 0 1px 1px #18c89b;
z-index: 1;
transform: translateY(95px);
animation: move 1.7s cubic-bezier(0.15,0.54,0.76,0.74);
animation-iteration-count: infinite;
}

.ocrloader:before,
.ocrloader:after,
.ocrloader em:after,
.ocrloader em:before {
border-color: #18c89b;
content: "";
position: absolute;
width: 45px;
height: 46px;
border-style: solid;
border-width: 0px;
}
.ocrloader:before {
left: 0;
top: 0;
border-left-width: 5px;
border-top-width: 5px;
border-radius: 5px 0 0 0;
}
.ocrloader:after {
right: 0;
top: 0;
border-right-width: 5px;
border-top-width: 5px;
border-radius: 0 5px 0 0;
}
.ocrloader em:before {
left: 0;
bottom: 0;
border-left-width: 5px;
border-bottom-width: 5px;
border-radius: 0 0 0 5px;
}
.ocrloader em:after {
right: 0;
bottom: 0;
border-right-width: 5px;
border-bottom-width: 5px;
border-radius: 0 0 5px 0;
}

@keyframes move {
0%,
100% {
transform: translateY(190px);
}
50% {
transform: translateY(0%);
}
75% {
transform: translateY(160px);
}
}

@keyframes blinker {
50% { opacity: 0; }
}
<div class="ocrloader">
<p>Scanning</p>
<em></em>
<span></span>
</div>

CodePen 上的完整示例

最佳答案

这是一个使用 box-shadow 的想法和 clip-path

.box {
width:200px;
height:200px;
margin:20px;
outline:2px solid;
outline-offset:10px;
position:relative;
}
.box::before {
content:"";
position:absolute;
top:0;
bottom:0;
left:0;
width:20px;
background:#18c89b;
box-shadow:0 0 70px 20px #18c89b;
clip-path:inset(0);
animation:
x 0.5s ease-in-out infinite alternate,
y 1s ease-in-out infinite;
}

@keyframes x {
to {
transform:translateX(-100%);
left:100%;
}
}

@keyframes y {
33% {
clip-path:inset(0 0 0 -100px);
}
50% {
clip-path:inset(0 0 0 0);
}
83%{
clip-path:inset(0 -100px 0 0);
}
}
<div class="box">

</div>

关于css - 如何实现扫描条动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66562406/

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