web前端学习互联网科技让前端飞

超级css制作水滴入池效果

2018-03-01  本文已影响57人  烟雨丿丶蓝
web前端群,189394454,有视频、源码、学习方法等大量干货分享

对于很多人来说css只是用来给网页上色的代码,其实css还是有很多很有趣的东西哦,除了用css来上色之外,还可以用css来写一些有趣的效果你就会发先css还是蛮有用的。
👇html代码:

<div class="drip"></div>

👇css代码:

  <style>
html, body {
  margin: 0;
  height: 100%;
  width: 100%;
  display: flex;
  background-color: #43A2CE;
}

.drip {
  width: 200px;
  height: 250px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin: auto;
  position: relative;
}
.drip:before {
  position: absolute;
  left: 92.5px;
  top: 0;
  content: '';
  width: 15px;
  height: 15px;
  background-color: #FFF;
  border-radius: 50%;
  opacity: 0;
  animation: drip 4s ease infinite;
}
.drip:after {
  box-sizing: border-box;
  position: absolute;
  bottom: 0;
  left: 0;
  content: '';
  width: 0px;
  height: 0px;
  border: solid 4px #FFF;
  border-radius: 50%;
  opacity: 0;
  animation: splash 4s ease infinite;
}

@keyframes drip {
  10% {
    top: 0;
    opacity: 1;
    animation-timing-function: cubic-bezier(0.24, 0, 0.76, 0.14);
  }
  25% {
    opacity: 1;
    top: 200px;
    animation-timing-function: ease-out;
    width: 15px;
    height: 15px;
    left: 92.5px;
  }
  30% {
    opacity: 1;
    top: 160px;
    width: 5px;
    height: 5px;
    animation-timing-function: ease-in;
    left: 97.5px;
  }
  33% {
    top: 200px;
    opacity: 0;
    animation-timing-function: ease-out;
    left: 97.5px;
  }
  33.001% {
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}
@keyframes splash {
  0% {
    opacity: 0;
  }
  25% {
    bottom: 50px;
    left: 100px;
    opacity: 0;
    width: 0px;
    height: 0px;
  }
  25.001% {
    opacity: 1;
  }
  33% {
    bottom: 0;
    left: 0;
    opacity: 0;
    width: 200px;
    height: 100px;
  }
  33.001% {
    bottom: 50px;
    left: 100px;
    opacity: 1;
    width: 0px;
    height: 0px;
  }
  43% {
    bottom: 0;
    left: 0;
    opacity: 0;
    width: 200px;
    height: 100px;
  }
  43.001% {
    opacity: 0;
  }
}

  </style>
上一篇下一篇

猜你喜欢

热点阅读