css3滑鼠懸浮小球彈性效果

admin發表於2017-03-20

分享一段程式碼例項,它實現了滑鼠懸浮小球彈性效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
@keyframes btn-pudding {
  12%,15% {
    transform: scale(0.93, 1.07);
  }
  16%,17% {
    transform: scale(0.94, 1.06);
  }
  10%,18% {
    transform: scale(0.95, 1.05);
  }
  19% {
    transform: scale(0.96, 1.04);
  }
  20% {
    transform: scale(0.98, 1.02);
  }
  21%,40%,48% {
    transform: scale(0.99, 1.01);
  }
  22%,23%,37%,39%,49% {
    transform: scale(1, 1);
  }
  7%,24%,34%,36% {
    transform: scale(1.01, 0.99);
  }
  25%,27%,30%,33% {
    transform: scale(1.02, 0.98);
  }
  28%,29% {
    transform: scale(1.03, 0.97);
  }
  2% {
    transform: scale(1.16, 0.84);
  }
  0% {
    transform: scale(1.2, 0.8);
  }
}
.back-to-top {
  width: 35px;
  height: 35px;
  position: fixed;
  z-index: 4;
  border-radius: 50%;
}
.back-to-top .to-top {
  width: 35px;
  height: 35px;
  position: fixed;
  z-index: 3;
  border-radius: 50%;
  color: #fff;
  opacity: 1;
  cursor: pointer;
  text-align: center;
  background-color: #00b2c2;
}
.back-to-top:hover .to-top {
  -webkit-animation: btn-pudding 1s linear;
  animation: btn-pudding 1s linear;
}
.top {
  display: block;
  width: 0px;
  height: 0px;
  border-bottom: 10px solid #fff;
  border-left: 5px solid #00b2c2;
  border-right: 5px solid #00b2c2;
  margin: 11px 37%;
}
</style>
</head>
<body>
  <div class="back-to-top">
    <div class="to-top"><i class="top"></i></div>
  </div>
</body>
</html>

相關文章