div+css实现环形点状亮色暗色切换的loading加载动画效果代码

代码语言:html

所属分类:加载滚动

代码描述:div+css实现环形点状亮色暗色切换的loading加载动画效果代码

代码标签: div css 环形 点状 亮色 暗色 切换 loading 加载 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
  
<style>
: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(.........完整代码请登录后点击上方下载按钮下载查看

网友评论0