文章数量
36
访客量
4952
访问量
9817

css特效之立体感加载效果

阅读量:314
更新时间:2023-12-11 13:57:34

使用HTML和CSS代码创建了一个具有立体感的加载效果,可以用作网页加载时的加载动画,以实现一个有趣的加载动画。

效果预览:效果预览
源码下载:关注公众号【RMRF】,回复【css15】可获取源码

HTML

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

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>立体感loading加载效果</title>
  <link rel="stylesheet" href="./css/index.css">
</head>

<body>
  <div id="app">
    <div class="loader"></div>
    <div class="tip">
      <span>loading</span>
      <div class="dot"></div>
      <div class="dot"></div>
      <div class="dot"></div>
    </div>
  </div>
</body>

</html>

CSS

* {
  padding: 0px;
  margin: 0px;
}

#app {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  background: #202020;
}

.loader {
  transform: rotateZ(45deg);
  perspective: 500px;
  width: 60px;
  height: 60px;
  color: #00ff2f;
}

.loader:before,
.loader:after {
  content: '';
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: inherit;
  height: inherit;
  border-radius: 50%;
  transform: rotateX(70deg);
  animation: 1s spin linear infinite;
}

.loader:after {
  color: #ff0000;
  transform: rotateY(70deg);
  animation-delay: .4s;
}

.tip {
  display: flex;
  align-items: flex-end;
  margin-top: 10px;
}

.tip span {
  font-weight: bold;
  color: #888;
}

.tip .dot {
  content: "";
  display: block;
  width: 3px;
  height: 3px;
  -webkit-animation: dots 2s infinite linear;
  animation: dots 2s infinite linear;
  background-color: #fff;
  margin-left: 5px;
}

.dot:nth-child(1) {
  -webkit-animation-delay: 0.4s;
  animation-delay: 0.4s;
}

.dot:nth-child(2) {
  -webkit-animation-delay: 0.8s;
  animation-delay: 0.8s;
}

.dot:nth-child(3) {
  -webkit-animation-delay: 1.2s;
  animation-delay: 1.2s;
}

@keyframes spin {

  0%,
  100% {
    box-shadow: 0.2em 0px 0 0px;
  }

  12% {
    box-shadow: 0.2em .2em 0 0;
  }

  25% {
    box-shadow: 0 0.2em 0 0px;
  }

  37% {
    box-shadow: -0.2em 0.2em 0 0;
  }

  50% {
    box-shadow: -0.2em 0 0 0;
  }

  62% {
    box-shadow: -0.2em -0.2em 0 0;
  }

  75% {
    box-shadow: 0px -0.2em 0 0;
  }

  87% {
    box-shadow: 0.2em -0.2em 0 0;
  }
}

@-webkit-keyframes dots {
  0% {
    background-color: rgba(255, 255, 255, 0.3);
  }

  30% {
    background-color: #fff;
  }

  70%,
  100% {
    background-color: rgba(255, 255, 255, 0.3);
  }
}

@keyframes dots {
  0% {
    background-color: rgba(255, 255, 255, 0.3);
  }

  30% {
    background-color: #fff;
  }

  70%,
  100% {
    background-color: rgba(255, 255, 255, 0.3);
  }
}