7、css3实现边框不停地跑动效果

效果例图:

1、上html代码:

html 复制代码
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" href="./3.css" />
    <title>Document</title>
</head>

<body>
    <div class="container">
        <div class="box">
            中国云南昆明
            <span class="line"></span>
            <span class="line"></span>
            <span class="line"></span>
            <span class="line"></span>
        </div>
    </div>
</body>
</html>

2、上css代码:

css 复制代码
.container{
    width: 800px;
    height: 680px;
    margin: 20px auto;
    position: relative;
}
.box{
    width: 420px;
    height: 210px;
    margin: 100px auto;
    line-height: 210px;
    text-align: center;
    font-size: 40px;
    position: relative;
    overflow: hidden;
    border: 1px solid #eee;
    font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    font-weight: 700;
    letter-spacing: 0.6em;
}
.line{
    position: absolute;
}
.line:nth-child(1){
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg,transparent, #008c8c);
    animation: move1 8s linear infinite;
}
@keyframes move1 {
    0%{
        left: -100%;
    }
    50%,
    100%{
        left: 100%;
    }    
}
.line:nth-child(2){
    top: -100%;
    right: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg,transparent, #008c8c);
    animation: move2 8s linear infinite;
    animation-delay: 2s;
}
@keyframes move2 {
    0%{
        top: -100%;
    }
    50%,
    100%{
        top: 100%;
    } 
}


.line:nth-child(3){
    bottom: 0;
    right: -100%;
    width: 100%;
    height: 4px;
    background: linear-gradient(270deg,transparent, #008c8c);
    animation: move3 8s linear infinite;
    animation-delay: 4s;
}
@keyframes move3 {
    0%{
        right: -100%;
    }
    50%,
    100%{
        right: 100%;
    } 
}
.line:nth-child(4){
    bottom: -100%;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(360deg,transparent, #008c8c);
    animation: move4 8s linear infinite;
    animation-delay: 6s;
}
@keyframes move4 {
    0%{
        bottom: -100%;
    }
    50%,
    100%{
        bottom: 100%;
    }
}
相关推荐
明月_清风几秒前
pwa 安装/离线/推送/后台同步 全套高级能力
前端·pwa
cyber_两只龙宝3 分钟前
Tomcat--企业级web应用服务器详细介绍与整合Nginx配置流程
linux·运维·前端·nginx·云原生·tomcat·负载均衡
明月_清风3 分钟前
Service Worker 和 Workbox 分别是什么?它们有什么区别?
前端·pwa
程序哥聊面试7 分钟前
TypeScript 入门
前端·javascript·typescript
亿元程序员12 分钟前
俄罗斯方块谁不会做......啊?流沙版?
前端
bai_lan_ya17 分钟前
嵌入式linux学习--makefile的使用以及通用解析
开发语言·前端·javascript
dustcell.20 分钟前
高性能web服务器
android·服务器·前端
GISer_Jing20 分钟前
Taro全栈学习路线与实战指南:从基础语法到工程化、性能优化深度进阶
前端·react.js·taro
两个西柚呀23 分钟前
每日前端面试题-如何判断空对象,如何区分数据类型
前端
一只理智恩28 分钟前
基于 CesiumJS + React + Go 实现三维无人机编队实时巡航可视化系统
前端·人工智能·算法·golang·无人机