css3代码做一个动态加载效果

476 ℃

利用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代码编写45款按钮效果

推荐一个纯CSS实现的各种动画加载效果的网站——CSS Loaders

标签: CSS Loaders, css3代码, css动态加载效果

上面是“css3代码做一个动态加载效果”的全面内容,想了解更多关于 前端知识 内容,请继续关注web建站教程。

当前网址:https://m.ipkd.cn/webs_13890.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

van-collapse-item折叠面板判断,有内容显示箭头可点击
帝国cms 复选框字段分隔去掉最后一个值得分隔符
37游戏盒子
PHP语法如何动态地向数组中添加元素
织梦cms提示错误:Unknown column oldplace in field list