如何利用css3实现光点随着指定位置跑,下面编程教程网小编给大家简单介绍一下具体实现代码!
1、画一个正方形(在正方形跑圈)
<div class="box run">光点跑动~</div>
2、css3代码
.box {
height: 500px;
width: 400px;
box-shadow: 0 0 2px orange;
text-align: center;
line-height: 260px;
}
.run {
background-image: linear-gradient(90deg, rgba(196, 233, 64, 0) 0%, rgb(62, 224, 84) 100%), linear-gradient(0deg, rgb(62, 224, 84) 0%, rgba(196, 233, 64, 0) 100%), linear-gradient(-90deg, rgba(196, 233, 64, 0) 0%, rgb(62, 224, 84) 100%), linear-gradient(0deg, rgba(196, 233, 64, 0) 0%, rgb(62, 224, 84) 100%);
background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
background-size: 100px 4px, 4px 100px, 100px 4px, 4px 100px;
background-position: -100px 1px, calc(100% - 1px) -100px, calc(100% + 100px) calc(100% - 1px), 1px 0px;
animation: moveLine 8s infinite linear;
height: calc(100% - 2px);
padding: 1px;
background-clip: content-box;
}
@keyframes moveLine {
0% {
background-position: -100px 1px, calc(100% - 1px) -100px, calc(100% + 100px) calc(100% - 1px), 1px 0px;
}
5% {
background-position: 0px 1px, calc(100% - 1px) -100px, calc(100% + 100px) calc(100% - 1px), 1px -100px;
}
30% {
background-position: 100% 1px, calc(100% - 1px) -100px, calc(100% + 100px) calc(100% - 1px), 1px -100px;
}
35% {
background-position: calc(100% + 100px) 1px, calc(100% - 1px) 0px, calc(100% + 100px) calc(100% - 1px), 1px -100px;
}
50% {
background-position: calc(100% + 100px) 1px, calc(100% - 1px) 100%, calc(100% + 100px) calc(100% - 1px), -100px -100px;
}
55% {
background-position: calc(100% + 100px) 1px, calc(100% - 1px) calc(100% + 100px), 100% calc(100% - 1px), -100px calc(100% + 100px);
}
80% {
background-position: calc(100% + 100px) 1px, calc(100% - 1px) calc(100% + 100px), 0px calc(100% - 1px), 1px calc(100% + 100px);
}
85% {
background-position: calc(100% + 100px) 1px, calc(100% - 1px) calc(100% + 100px), -100px calc(100% - 1px), 1px 100%;
}
100% {
background-position: calc(100% + 100px) 1px, calc(100% - 1px) calc(100% + 100px), -100px calc(100% - 1px), 1px 0px;
}
}
以上是编程学习网小编为您介绍的“css3如何实现光点随着指定位置跑”的全面内容,想了解更多关于 前端知识 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:css3如何实现光点随着指定位置跑


猜你喜欢
- 异步调用webservice返回responseXML为空的问题解决方法 2024-01-17
- 纯JS打造网页中checkbox和radio的美化效果 2023-12-01
- vue3.0 router路由跳转传参问题(router.push) 2024-01-14
- CSS 使用radial-gradient 实现优惠券样式 2024-02-25
- vue项目因为空格报错怎么解决 2025-01-15
- PC端和移动端自适应问题的快速解决方法 2024-02-20
- 使用CSS画爱心的过程详解 2024-02-25
- ajax文件上传成功 解决浏览器兼容问题 2022-12-28
- 原生JS实现的轮播图功能详解 2024-01-05
- 举例详解CSS的z-index属性的使用 2023-12-15