css3實現網狀球體效果程式碼例項

antzone發表於2017-02-20
分享一段程式碼例項,它實現了旋轉的網狀球體效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
* {
  margin:0; 
  padding:0;
  box-sizing: border-box;
}
body {
  background:black;
}
.wrap {
  margin: 150px auto;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
.wrap, .ball, .yCenter, .zCenter ,.xCenter{
  width: 200px;
  height: 200px;
  border-radius: 50%;
}
.x1, .x2,  .y1, .y2, .z1, .z2,.yCenter, .zCenter ,.xCenter {
  position: absolute;
}
.x1,.x2,.y1,.y2,.z1,.z2 {
  width: 87.5%;
  height: 87.5%;
  border-radius: 50%;
}
.ball {
  position: relative;
  transform-style: preserve-3d;
  animation: move 10s linear infinite;
}
.ball .x{
  top:0;
  left:0;
  border: 2px solid #FF0099;
  transform:translateY(100px);
}
.ball .y{
  top:0;
  left:0;
  border: 2px solid #a440fb;
  transform:rotateY(90deg) translateY(100px);
}
.ball .z{
  top:0;
  left:0;
  border: 2px solid #ffff4f;
  transform:rotateZ(90deg) translateX(100px);
}
.ball .x1{
  top:6%;
  left:6%;
  border: 1px solid #FF0099;
  transform:rotateX(90deg) translateZ(50px);
}
.ball .x2{
  top:6%;
  left:6%;
  border: 1px solid #FF0099;
  transform:rotateX(270deg) translateZ(50px);
}
.ball .y1{
  top:6%;
  left:6%;
  border: 1px solid #a440fb;
  transform:rotateY(90deg) translateZ(50px);
}
.ball .y2{
  top:6%;
  left:6%;
  border: 1px solid #a440fb;
  transform:rotateY(270deg) translateZ(50px);
}
.ball .z1{
  top:6%;
  left:6%;
  border: 1px solid #ffff4f;
  transform:rotateZ(90deg) translateZ(50px);
}
.ball .z2{
  top:6%;
  left:6%;
  border: 1px solid #ffff4f;
  transform:rotateZ(270deg) translateZ(-50px);
}
.ball .xCenter{
  width:100%;
  left:0%;
  border: 2px solid #FF0099;
  transform:rotateX(90deg);
}
.ball .yCenter{
  top:0;
  left:0;
  border: 2px solid #a440fb;
  transform:rotateY(90deg) ;
}
.ball .zCenter{
  width:100%;
  left:0;
  border: 2px solid #ffff4f;
  transform:rotateZ(90deg) ;
}
@keyframes move{
  100% { transform:  rotateX(360deg) rotateY(360deg) }
}
</style>
</head>
<body>
<div class="wrap">
  <div class="ball">
    <div class="x1"></div>
    <div class="x2"></div>
    <div class="xCenter"></div>
    <div class="x"></div>
 
    <div class="y1"></div>
    <div class="yCenter"></div>
    <div class="y2"></div>
    <div class="y"></div>
 
    <div class="z1"></div>
    <div class="zCenter"></div>
    <div class="z2"></div>
    <div class="z"></div>
  </div>
</div>
</body>
</html>

相關文章