CSS3 div從左側滑入效果程式碼例項

antzone發表於2017-03-12

分享一段程式碼例項,它實現了div從左側滑入的效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
div{
  margin:200px;
  width:150px;
  height:100px;
  background:green;
  animation: bounceInLeft 1s infinite cubic-bezier(0.215, 0.610, 0.355, 1.000)
}
@keyframes bounceInLeft {
  0% {
    opacity: 0;
    transform: translate3d(-3000px, 0, 0);
  }
  60% {
    opacity: 1;
    transform: translate3d(25px, 0, 0);
  }
  75% {
    transform: translate3d(-10px, 0, 0);
  }
  90% {
    transform: translate3d(5px, 0, 0);
  }
  100% {
    transform: none;
  }
}
</style>
</head>
<body>
  <div></div>
</body>
</html>

上面的程式碼實現了我們的要求,更多內容可以參閱相關閱讀。

相關閱讀:

(1).animation屬性參閱CSS3 animation一章節。

(2).@keyframes參閱CSS3 @keyframes一章節。

(3).transform:translate3d()參閱CSS3 translate3d(x,y,z)一章節。

(4).transform: rotate3d()參閱CSS3 rotate3d(x,y,z,angle)一章節。

相關文章