CSS3 旋轉太極八卦圖程式碼例項

admin發表於2017-05-04

分享一個程式碼例項,它利用CSS3實現了旋轉的太極八卦圖效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
body{
  background-color: #ccc;
}
.box{
  width: 400px;
  height: 400px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 50%;
  overflow: hidden;
  -webkit-transition: all 3s;
  -webkit-animation: cd 3000ms infinite linear ;
  -o-animation: cd 3000ms infinite linear ;
  animation: cd 3000ms infinite linear ;
}
@-webkit-keyframes cd {
  0% { -webkit-transform:  rotate(0deg); }
  50%{-webkit-transform:rotate(-180deg) ;}
  100% { -webkit-transform: rotate(-360deg); }
}
.l{ 
  width: 200px;
  height: inherit;
  background-color: #000; 
}
.r{ 
  width: 200px;
  height: inherit;
  background-color: #fff;
}
.c{ 
  width: 200px;
  height: inherit; 
  position: absolute; 
  margin-left: -100px;
  left: 50%;
  top:0;
}
.wc{
  width: 60px;
  height:60px;
  border:70px solid #fff;
  background-color: #000;
  border-radius: 50%;
}
.bc{
  width: 60px;
  height:60px;
  border:70px solid #000;
  background-color: #fff;
  border-radius: 50%;	
}
</style>
</head>
<body>
  <div class="box">
    <div class="l"></div>
    <div class="r"></div>
    <div class="c">
    <div class="bc"></div>
    <div class="wc"></div>	
  </div>
</div>
</body>
</html>

相關文章