CSS3水滴向下滴落動畫效果

admin發表於2018-05-21
本章節分享一段程式碼例項,它實現了水滴下落的拉伸效果。

不過看起來有一點點的邪惡,我們們就不去計較了,程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
body, html {
  margin: 0;
  background-color: #fff;
}
.content {
  position: absolute;
  z-index: 10;
}
.father {
  position: absolute;
  top: 0px;
  bottom: 0px;
  width: 100%;
  background-color: #fff;
  margin: -50px 0px;
  -webkit-filter: contrast(100);
  z-index: 1;
}
.big {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  margin: -100px -100px;
  background-color: #f00;
  border-radius: 50%;
  -webkit-filter: blur(20px);
  z-index: 100;
}
.small {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  margin: 140px 0px;
  background-color: #f00;
  border-radius: 50%;
  -webkit-filter: blur(20px);
  animation-name: 'change1';
  animation-duration: 5s;
  animation-iteration-count: infinite;
}
 
.center {
  position: absolute;
  width: 40px;
  height: 200px;
  background-color: #f00;
  -webkit-filter: blur(20px);
  top: 50%;
  left: 50%;
  margin: -30px -70px;
  animation-name: 'change2';
  animation-duration: 5s;
  animation-iteration-count: infinite;
}
@keyframes change1 {
  0% {
    margin: -85px -90px;
  }
  50% {
    margin: 50px -90px;
  }
  100% {
    margin: -85px -90px;
  }
}
@-keyframes change2 {
  0% {
    height: 0px;
  }
  50% {
    height: 100px;
  }
  100% {
    height: 0px;
  }
}
</style>
</head>
<body>
<div class="father">
  <div class="center"></div>
  <div class="big"></div>
  <div class="small"></div>
</div>
</body>
</html>

相關文章