CSS3 loadding載入效果

antzone發表於2018-05-20

分享一段程式碼例項,它實現了四小球loadding載入效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
.container{
  width: 300px;
  height: 300px;
  position: relative;
  margin:50px auto;
}
.circle{
  width: 100px;
  height: 100px;
  position: absolute;
  border-radius: 50%;
}
#one{
  left: 0;
  top: 0;
  background:#f00;
  animation: move1 2s ease-in-out infinite;
}
#two{
  right: 0;
  top: 0;
  background:#000;
  animation: move2 2s ease-in-out infinite;
}
#three{
  left: 0;
  bottom: 0;
  background:blue;
  animation: move3 2s ease-in-out infinite;
}
#four{
  right: 0;
  bottom: 0;
  background:yellow;
  animation: move4 2s ease-in-out infinite;
}
/*動畫*/
@keyframes move1{
  0%{transform: translate(0,0)}
  50%{transform: translate(200px,200px)}
  100%{transform: translate(0,0)}
}
@keyframes move2{
  0%{transform: translate(0,0)}
  50%{transform: translate(-200px,200px)}
  100%{transform: translate(0,0)}
}
@keyframes move3{
  0%{transform: translate(0,0)}
  50%{transform: translate(200px,-200px)}
  100%{transform: translate(0,0)}
}
@keyframes move4{
  0%{transform: translate(0,0)}
  50%{transform: translate(-200px,-200px)}
  100%{transform: translate(0,0)}
}
</style>
</head>
<body>
<div class="container">
  <div class="circle" id="one"></div>
  <div class="circle" id="two"></div>
  <div class="circle" id="three"></div>
  <div class="circle" id="four"></div>
</div>
</body>
</html>

相關文章