利用html+css3代码做一个简单的动态加载效果,下面是具体实现代码,可以直接复制查看效果!
html代码
<input type="checkbox"/>
<div class="bg"></div>
<div class="content">
<div class="dots">
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="dot"><span></span></div>
<div class="ring"></div>
</div>
</div>
css代码
:root {
--w: #fafafa;
--b: #141414;
--s: 1s;
--d: calc(var(--s) / 6);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
overflow: hidden;
}
input {
width: 100vw;
height: 100vh;
position: absolute;
z-index: 4;
opacity: 0;
cursor: pointer;
}
input:checked ~ div {
filter: invert(1);
}
input:checked + .bg:before {
content: "CLICK TO DARK";
}
.bg:before {
content: "CLICK TO LIGHT";
position: absolute;
color: var(--w);
width: 100%;
text-align: center;
bottom: 10vh;
font-family: Arial, Helvetica, serif;
font-size: 12px;
text-shadow: 0 0 1px var(--w);
opacity: 0.25;
}
body, .content, .dots {
display: flex;
align-items: center;
justify-content: center;
}
.bg {
width: 100vw;
height: 100vh;
position: absolute;
background: var(--b);
z-index: -2;
}
.content {
width: 50vmin;
height: 50vmin;
background: #f000;
animation: spin 8s linear 0s infinite;
}
.dots {
background: #0ff0;
width: 100%;
height: 100%;
position: relative;
}
.ring {
border: 1.5vmin solid var(--w);
width: 64%;
height: 64%;
border-radius: 100%;
z-index: 0;
box-shadow: 0 0 0 1vmin var(--b), 0 0 0 1vmin var(--b) inset;
animation: spin 8s linear 0s infinite reverse;
}
.dot {
width: 50%;
position: absolute;
height: 7vmin;
background: #f000;
left: 0;
transform-origin: 100% 50%;
z-index: -1;
animation: over-ring calc(var(--s) * 2) linear 0s infinite;
}
.dot span {
width: 5.5vmin;
height: 5.5vmin;
left: 0;
border: 1vmin solid var(--b);
position: absolute;
background: var(--w);
border-radius: 100%;
animation: ball var(--s) ease-in-out 0s infinite alternate;
}
.dot:nth-child(1) {
transform: rotate(-30deg);
animation-delay: calc(var(--d) * 0);
}
.dot:nth-child(1) span {
animation-delay: calc(var(--d) * 0);
}
.dot:nth-child(2) {
transform: rotate(-60deg);
animation-delay: calc(var(--d) * -1);
}
.dot:nth-child(2) span {
animation-delay: calc(var(--d) * -1);
}
.dot:nth-child(3) {
transform: rotate(-90deg);
animation-delay: calc(var(--d) * -2);
}
.dot:nth-child(3) span {
animation-delay: calc(var(--d) * -2);
}
.dot:nth-child(4) {
transform: rotate(-120deg);
animation-delay: calc(var(--d) * -3);
}
.dot:nth-child(4) span {
animation-delay: calc(var(--d) * -3);
}
.dot:nth-child(5) {
transform: rotate(-150deg);
animation-delay: calc(var(--d) * -4);
}
.dot:nth-child(5) span {
animation-delay: calc(var(--d) * -4);
}
.dot:nth-child(6) {
transform: rotate(-180deg);
animation-delay: calc(var(--d) * -5);
}
.dot:nth-child(6) span {
animation-delay: calc(var(--d) * -5);
}
.dot:nth-child(7) {
transform: rotate(-210deg);
animation-delay: calc(var(--d) * -6);
}
.dot:nth-child(7) span {
animation-delay: calc(var(--d) * -6);
}
.dot:nth-child(8) {
transform: rotate(-240deg);
animation-delay: calc(var(--d) * -7);
}
.dot:nth-child(8) span {
animation-delay: calc(var(--d) * -7);
}
.dot:nth-child(9) {
transform: rotate(-270deg);
animation-delay: calc(var(--d) * -8);
}
.dot:nth-child(9) span {
animation-delay: calc(var(--d) * -8);
}
.dot:nth-child(10) {
transform: rotate(-300deg);
animation-delay: calc(var(--d) * -9);
}
.dot:nth-child(10) span {
animation-delay: calc(var(--d) * -9);
}
.dot:nth-child(11) {
transform: rotate(-330deg);
animation-delay: calc(var(--d) * -10);
}
.dot:nth-child(11) span {
animation-delay: calc(var(--d) * -10);
}
.dot:nth-child(12) {
transform: rotate(-360deg);
animation-delay: calc(var(--d) * -11);
}
.dot:nth-child(12) span {
animation-delay: calc(var(--d) * -11);
}
@keyframes spin {
100% {
transform: rotate(-360deg);
}
}
@keyframes ball {
100% {
left: 12vmin;
width: 4vmin;
height: 4vmin;
}
}
@keyframes over-ring {
0%, 50% {
z-index: -1;
}
51%, 100% {
z-index: 1;
}
}
以上是编程学习网小编为您介绍的“css3代码做一个动态加载效果”的全面内容,想了解更多关于 前端知识 内容,请继续关注编程基础学习网。
织梦狗教程
本文标题为:css3代码做一个动态加载效果


基础教程推荐
猜你喜欢
- Entity Framework Code First数据库连接 转载 https://www.cnblogs.com/libingql/p/3351275.html 2023-10-26
- CSS 鼠标样式和手指样式整理 2023-12-29
- CSS小技巧 导航中鼠标经过变换文字的实现代码 2023-12-28
- JavaScript用JSONP跨域请求数据实例详解 2024-01-07
- 通过css3动画和opacity透明度实现呼吸灯效果 2024-02-07
- 关于JavaScript的Array数组方法详解 2023-07-09
- vue打包成功后直接将文件上传到oss 2023-10-08
- 韩国商业网站设计分析 2022-11-06
- 图文示例讲解useState与useReducer性能区别 2023-07-10
- ajax三级联动的实现方法 2023-01-31