css3實現環狀旋轉效果

admin發表於2017-03-30

分享一段程式碼例項,它利用css3實現了環狀旋轉效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
* {
  margin: 0;
  padding: 0;
}
.opt {
  display: inline-block;
  height: 200px;
  position: relative;
  overflow: hidden;
}
.ari {
  margin: 20px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border-width: 5px;
  border-color: #000000;
  border-style: solid;
  position: relative;
  z-index: 99;
  animation: mymove 3s;
  -webkit-animation: mymove 3s;
  animation-fill-mode: forwards;
  -webkit-animation-fill-mode: forwards;
}
@keyframes mymove {
  0%,100% {
    border-left-color: red;
  }
  50%,75% {
    border-left-color: red;
    border-bottom-color: red;
  }
  75%,100% {
    border-left-color: red;
    border-bottom-color: red;
    border-right-color: red;
  }
  from {
    transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -webkit-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
  }
  to {
    transform: rotate(180deg);
    -ms-transform: rotate(180deg);
    -moz-transform: rotate(180deg);
    -webkit-transform: rotate(180deg);
    -o-transform: rotate(180deg);
  }
}
@-webkit-keyframes mymove {
  0%,100% {
    border-left-color: red;
    border-top-color: red;
    border-right-color: red;
  }
  from {
    transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -webkit-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
  }
  to {
    transform: rotate(0deg);
    -ms-transform: rotate(0deg);
    -moz-transform: rotate(0deg);
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
  }
}
.hide {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: block;
  opacity: 0;
  animation: ceshow 3s;
  -webkit-animation: ceshow 3s;
  animation-fill-mode: forwards;
  -webkit-animation-fill-mode: forwards;
}
@-webkit-keyframes ceshow {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.pv rect {
  width: 300px;
  height: 300px;
  border-radius: 300px;
  -webkit-transition: all 1300ms ease;
  -moz-transition: all 1300ms ease;
  -o-transition: all 1300ms ease;
  transition: all 1300ms ease;
}
</style>
</head>
<body>
<div class="opt">
  <div class="ari"></div>
  <div class="hide">正常</div>
</div>
</body>
</html>

相關文章