css3實現旋轉的太極圖效果程式碼例項

admin發表於2017-02-22
下面分享一段程式碼例項,它使用css3實現了太極圖的效果。

並且能夠自動旋轉,程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
* {
  margin: 0;
  padding: 0;
}
html {
  font-size: 62.5%;
}
body {
  font-family: "mircoft yahei";
  font-size: 14px;
  font-size: 1.4rem;
  line-height: 1;
  height: 1500px;
}
.taiji {
  margin: 100px auto;
  width: 500px;
  height: 260px;
  background-color: #fff;
  border-color: #000;
  border-style: solid;
  border-width: 2px 2px 250px 2px;
  border-radius: 100%;
  position: relative;
  animation: myfirst 5s ease-in-out 0s infinite;
  /* Firefox: */
  -moz-animation: myfirst 5s ease-in-out 0s infinite;
  /* Safari 和 Chrome: */
  -webkit-animation: myfirst 5s ease-in-out 0s infinite;
  /* Opera: */
  -o-animation: myfirst 5s ease-in-out 0s infinite;
}
.taiji:before {
  position: absolute;
  content: '';
  top: 50%;
  left: 0;
  width: 50px;
  height: 50px;
  background-color: #fff;
  border: 100px solid #000;
  border-radius: 100%;
}
.taiji:after {
  position: absolute;
  content: '';
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  background-color: #000;
  border: 100px solid #fff;
  border-radius: 100%;
}
@keyframes myfirst {
  0% {
    -webkit-transform: rotateZ(0deg);
    -moz-transform: rotateZ(0deg);
    -ms-transform: rotateZ(0deg);
    -o-transform: rotateZ(0deg);
    transform: rotateZ(0deg);
  }
  100% {
    -webkit-transform: rotateZ(360deg);
    -moz-transform: rotateZ(360deg);
    -ms-transform: rotateZ(360deg);
    -o-transform: rotateZ(360deg);
    transform: rotateZ(360deg);
  }
}
@-webkit-keyframes myfirst {
  0% {
    -webkit-transform: rotateZ(0deg);
    -moz-transform: rotateZ(0deg);
    -ms-transform: rotateZ(0deg);
    -o-transform: rotateZ(0deg);
    transform: rotateZ(0deg);
  }
  100% {
    -webkit-transform: rotateZ(360deg);
    -moz-transform: rotateZ(360deg);
    -ms-transform: rotateZ(360deg);
    -o-transform: rotateZ(360deg);
    transform: rotateZ(360deg);
  }
}
@-moz-keyframes myfirst {
  0% {
    -webkit-transform: rotateZ(0deg);
    -moz-transform: rotateZ(0deg);
    -ms-transform: rotateZ(0deg);
    -o-transform: rotateZ(0deg);
    transform: rotateZ(0deg);
  }
  100% {
    -webkit-transform: rotateZ(360deg);
    -moz-transform: rotateZ(360deg);
    -ms-transform: rotateZ(360deg);
    -o-transform: rotateZ(360deg);
    transform: rotateZ(360deg);
  }
}
@-ms-keyframes myfirst {
  0% {
    -webkit-transform: rotateZ(0deg);
    -moz-transform: rotateZ(0deg);
    -ms-transform: rotateZ(0deg);
    -o-transform: rotateZ(0deg);
    transform: rotateZ(0deg);
  }
  100% {
    -webkit-transform: rotateZ(360deg);
    -moz-transform: rotateZ(360deg);
    -ms-transform: rotateZ(360deg);
    -o-transform: rotateZ(360deg);
    transform: rotateZ(360deg);
  }
}
</style>
</head>
<body>
<div class="taiji"></div>
</body>
</html>

相關文章