发布时间:2023-05-30 15:30
实现原理:
div的before元素当成左边框
内部一个class=bottom的i标签当下边框
div的after元素当成右边框
内部一个class=top的i标签当上边框
效果图:
原理图:
左边框:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>纯CSS3流光边框特效</title>
<style>
.fly_border {
border: 1px solid rgba(32, 254, 255, 0.3);
/* 宽高和相对定位是一定要给的,因为这会影响.animate-border子元素的定位 */
position: relative;
width: 400px;
height: 300px;
overflow: hidden;
margin: 200px auto;
}
.fly_border::before {
content: " ";
position: absolute;
width: 1px;
height: 100%;
top: -100%;
left: 0;
background-image: linear-gradient(
0deg,
transparent,
#03e9f4,
transparent
);
animation: two 4s linear infinite;
}
.fly_border::after {
content: " ";
position: absolute;
width: 1px;
height: 100%;
bottom: -100%;
right: 0;
background-image: linear-gradient(
360deg,
transparent,
#03e9f4,
transparent
);
animation: four 4s linear 2s infinite;
}
.fly_border i {
position: absolute;
display: inline-block;
height: 1px;
width: 100%;
}
.fly_border .bottom {
bottom: 0;
left: -100%;
background-image: linear-gradient(
270deg,
transparent,
#03e9f4,
transparent
);
animation: one 4s linear 1s infinite;
}
.fly_border .top {
top: 0;
right: -100%;
background-image: linear-gradient(
270deg,
transparent,
#03e9f4,
transparent
);
animation: three 4s linear 3s infinite;
}
body {
height: 100%;
background-color: #0f222b;
}
@keyframes one {
0% {
left: -100%;
}
50%,
100% {
left: 100%;
}
}
@keyframes two {
0% {
top: -100%;
}
50%,
100% {
top: 100%;
}
}
@keyframes three {
0% {
right: -100%;
}
50%,
100% {
right: 100%;
}
}
@keyframes four {
0% {
bottom: -100%;
}
50%,
100% {
bottom: 100%;
}
}
</style>
</head>
<body>
<div>
<div class="fly_border"><i class="top"></i><i class="bottom"></i></div>
</div>
</body>
</html>
参考资料:
青青子衿~~ vue 实现边框流光动画
路透社:谷歌已停止与华为部分合作;联想否认断供华为PC;微软计划直供Linux内核;谷歌无人机快递Wing进军芬兰……...
我想转行做软件测试,有必要报培训班吗?我听说好多人说自学就行...
硬核剧透!2022 开放原子全球开源峰会龙蜥专场 9 大议题、18 位大咖,7.27见
基于 Rainbond 部署 DolphinScheduler 高可用集群
【PIMF】开源鸿蒙首款IDE低代码(可视化界面)入门OpenHarmony应用
bartender的安全策略不允许指定的用户执行此操作_如何以非root用户运行Docker容器...
【Python爬虫 • selenium】selenium4新版本使用指南
SpringCloud Alibaba微服务第9章之Gateway
oracle常用的修改表信息及其获取系统日期时间的sql语句