css3實現絢麗loadding載入效果

antzone發表於2017-03-13

分享一段程式碼例項,它實現了非常絢麗的loadding載入效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
body {
  background: #282828;
}
.overwatch {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 120px;
  height: 120px;
  margin: -80px 0px 0px -80px;
  background-color: transparent;
  border-radius: 50%;
  border: 20px solid #B6B8C0;
}
.overwatch div.across-line:after {
  content: "";
  height: 4px;
  width: 22px;
  background: #282828;
  position: absolute;
  top: 1px;
  left: 1px;
  transform: rotate(45deg);
  transform-origin: bottom left;
  z-index: 10;
}
.overwatch div.across-line:before {
  content: "";
  height: 4px;
  width: 22px;
  background: #282828;
  position: absolute;
  top: 15px;
  right: -5px;
  transform: rotate(-45deg);
  transform-origin: bottom left;
  z-index: 10;
}
.overwatch div.taper:after {
  content: "";
  border-width: 0 0 50px 20px;
  border-style: solid;
  border-color: transparent transparent #B6B8C0;
  width: 0;
  height: 0;
  position: absolute;
  right: 62px;
  bottom: 44px;
}
.overwatch div.taper:before {
  content: "";
  border-width: 0 20px 50px 0;
  border-style: solid;
  border-color: transparent transparent #B6B8C0;
  width: 0;
  height: 0;
  position: absolute;
  left: 63px;
  bottom: 44px;
}
.overwatch:after {
  content: "";
  height: 20px;
  width: 66px;
  background: #B6B8C0;
  position: absolute;
  bottom: -3px;
  left: 11px;
  transform: rotate(-45deg) skew(-45deg);
  transform-origin: bottom left;
}
.overwatch:before {
  content: "";
  height: 20px;
  width: 66px;
  background: #B6B8C0;
  position: absolute;
  bottom: 44px;
  right: -9px;
  transform: rotate(45deg) skew(45deg);
  transform-origin: bottom left;
}
.inner-ring {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 180px;
  height: 180px;
  margin: -100px 0px 0px -100px;
  background-color: transparent;
  border-radius: 50%;
  background-color: transparent;
  border-radius: 50%;
  border: 10px solid #F9D64A;
  clip: rect(90px, 200px, 110px, 100px);
  animation: rotate 3s linear infinite;
}
.inner-ring1 {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  margin: -100px 0px 0px -100px;
  background-color: transparent;
  border-radius: 50%;
  background-color: transparent;
  border-radius: 50%;
  animation: rotate21 2s linear infinite;
}
.inner-ring1 .inner-ring1-c {
  position: relative;
  width: 100px;
  height: 200px;
  overflow: hidden;
}
.inner-ring1 .inner-ring1-r {
  width: 180px;
  height: 180px;
  border: 10px solid transparent;
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 0;
  border-top: 10px solid #F9D64A;
  border-left: 10px solid #F9D64A;
  transform: rotate(0deg);
  animation: ring11 2s linear infinite;
}
.inner-ring2 {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  margin: -100px 0px 0px -100px;
  background-color: transparent;
  border-radius: 50%;
  background-color: transparent;
  border-radius: 50%;
  animation: rotate22 2s linear infinite;
}
.inner-ring2 .inner-ring2-c {
  position: relative;
  width: 100px;
  height: 200px;
  overflow: hidden;
}
.inner-ring2 .inner-ring2-r {
  width: 180px;
  height: 180px;
  border: 10px solid transparent;
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 0;
  border-top: 10px solid #F9D64A;
  border-left: 10px solid #F9D64A;
  transform: rotate(0deg);
  animation: ring12 2s linear infinite;
}
.inner-ring3 {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  margin: -100px 0px 0px -100px;
  background-color: transparent;
  border-radius: 50%;
  background-color: transparent;
  border-radius: 50%;
  animation: ring6 2s infinite linear;
}
.inner-ring3 .inner-ring3-p1-c {
  position: relative;
  float: left;
  width: 100px;
  height: 200px;
  overflow: hidden;
}
.inner-ring3 .inner-ring3-p1-r {
  width: 180px;
  height: 180px;
  border: 10px solid transparent;
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 0;
  border-top: 10px solid rgba(189, 186, 62, 0.25);
  border-left: 10px solid rgba(189, 186, 62, 0.25);
  transform: rotate(-45deg);
  animation: ring4 2s linear infinite;
}
.inner-ring3 .p1-an {
  width: 200px;
  height: 200px;
  position: absolute;
  top: 0;
  left: 0;
  animation: ring5 2s cubic-bezier(0, 0.5, 0.5, 1) infinite;
}
.inner-ring3 .inner-ring3-p2-c {
  position: relative;
  float: right;
  width: 100px;
  height: 200px;
  transform: rotate(180deg);
  overflow: hidden;
}
.inner-ring3 .inner-ring3-p2-r {
  width: 180px;
  height: 180px;
  border: 10px solid transparent;
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 0;
  border-top: 10px solid rgba(189, 186, 62, 0.25);
  border-left: 10px solid rgba(189, 186, 62, 0.25);
  transform: rotate(-45deg);
  animation: ring2 2s cubic-bezier(0.5, 0, 1, 0.5) infinite;
}
.inner-ring3 .p2-an {
  width: 200px;
  height: 200px;
  position: absolute;
  top: 0;
  left: 0;
  animation: ring3 2s linear infinite;
}
.outer-ring {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 220px;
  height: 220px;
  margin: -116px 0px 0px -116px;
  background-color: transparent;
  border-radius: 50%;
  border: 6px solid transparent;
}
.outer-ring:after {
  content: "";
  display: block;
  position: absolute;
  top: -6px;
  left: -6px;
  width: 220px;
  height: 220px;
  border: 6px solid rgba(161, 164, 176, 0.5);
  border-radius: 50%;
  clip: rect(112px, 232px, 120px, 100px);
  animation: rotate3602 3s linear infinite reverse;
}
.outer-ring:before {
  content: "";
  display: block;
  position: absolute;
  top: -6px;
  left: -6px;
  width: 220px;
  height: 220px;
  border: 6px solid rgba(161, 164, 176, 0.5);
  border-radius: 50%;
  clip: rect(105px, 232px, 127px, 100px);
  animation: rotate3603 3s cubic-bezier(0.34, 0.07, 0.68, 0.93) infinite;
}
.outer-ring2 {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 220px;
  height: 220px;
  margin: -116px 0px 0px -116px;
  background-color: transparent;
  border-radius: 50%;
  border: 6px solid transparent;
}
.outer-ring2:after {
  content: "";
  display: block;
  position: absolute;
  top: -6px;
  left: -6px;
  width: 220px;
  height: 220px;
  border: 6px solid rgba(161, 164, 176, 0.5);
  border-radius: 50%;
  transform: rotate(120deg);
  clip: rect(80px, 232px, 152px, 100px);
  animation: rotate3602 3s linear infinite;
}
.outer-ring2:before {
  content: "";
  display: block;
  position: absolute;
  top: -6px;
  left: -6px;
  width: 220px;
  height: 220px;
  border: 6px solid rgba(161, 164, 176, 0.5);
  border-radius: 50%;
  transform: rotate(230deg);
  clip: rect(60px, 232px, 172px, 100px);
  animation: rotate360 3s cubic-bezier(0.34, 0.07, 0.68, 0.93) infinite;
}
@keyframes rotate {
  0% {
    transform: rotate(360deg);
    clip: rect(96px, 200px, 108px, 100px);
  }
  50% {
    clip: rect(92px, 200px, 108px, 100px);
  }
  100% {
    clip: rect(96px, 200px, 108px, 100px);
    transform: rotate(0deg);
  }
}
@keyframes rotate21 {
  0% {
    transform: rotate(180deg);
  }
  50% {
    transform: rotate(270deg);
  }
  100% {
    transform: rotate(540deg);
  }
}
@keyframes rotate22 {
  0% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(90deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
@keyframes rotate360 {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
@keyframes rotate3602 {
  0% {
    transform: rotate(120deg);
  }
  100% {
    transform: rotate(480deg);
  }
}
@keyframes rotate3603 {
  0% {
    transform: rotate(270deg);
  }
  100% {
    transform: rotate(-90deg);
  }
}
@keyframes ring11 {
  0% {
    transform: rotate(-223deg);
  }
  50% {
    transform: rotate(-170deg);
  }
  100% {
    transform: rotate(-223deg);
  }
}
@keyframes ring12 {
  0% {
    transform: rotate(-205deg);
  }
  50% {
    transform: rotate(-135deg);
  }
  100% {
    transform: rotate(-205deg);
  }
}
@keyframes ring2 {
  0% {
    transform: rotate(-45deg);
  }
  35.5% {
    transform: rotate(135deg);
  }
  100% {
    transform: rotate(135deg);
  }
}
@keyframes ring3 {
  0% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(0deg);
  }
  64.5% {
    transform: rotate(180deg);
  }
  100% {
    transform: rotate(180deg);
  }
}
@keyframes ring4 {
  0% {
    transform: rotate(-45deg);
  }
  35.5% {
    transform: rotate(-45deg);
  }
  50% {
        transform: rotate(135deg);
      }
 
      100% {
        transform: rotate(135deg);
      }
}
@keyframes ring5 {
  0% {
    transform: rotate(0deg);
  }
  64.5% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(180deg);
  }
}
@keyframes ring6 {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
</style>
</head>
<body>
  <div class="overwatch">
    <div class="across-line"></div>
    <div class="taper"></div>
  </div>
  <div class="inner-ring3">
    <div class="inner-ring3-p1-c">
      <div class="p1-an">
        <div class="inner-ring3-p1-r"></div>
      </div>
    </div>
    <div class="inner-ring3-p2-c">
      <div class="p2-an">
        <div class="inner-ring3-p2-r"></div>
      </div>
    </div>
  </div>
  <div class="inner-ring"></div>
  <div class="inner-ring2">
    <div class="inner-ring2-c">
      <div class="inner-ring2-r"></div>
    </div>
  </div>
  <div class="outer-ring"></div>
  <div class="outer-ring2"></div>
</body>
</html>

相關文章