CSS3紙飛機程式碼例項

antzone發表於2018-06-02

分享一段程式碼例項,它利用css3實現了紙飛機效果,並且紙飛機能夠飛行一定的距離。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
* {
  margin: 0;
  padding: 0;
}
body {
  background: #f0ffff;
}
.airplane {
  width: auto;
  height: auto;
  position: absolute;
  top: 0;
  left: 0;
  -webkit-animation: move_plane 2s ease forwards;
  cursor: pointer;
}
@keyframes move_plane {
  100% {
    left: 500px;
    top: 200px;
  }
}
@keyframes move_top {
  100% {
    border-bottom: 100px solid #28935d;
    border-left: 170px solid transparent;
    border-right: 130px solid transparent;
  }
}
@keyframes move_af_top {
  100% {
    opacity: 1;
  }
}
@keyframes move_mid {
  100% {
    top: 200px;
    left: 171px;
    border-top: 130px solid #28935d;
    border-left: 174px solid transparent;
    border-right: 110px solid transparent;
    -webkit-transform: rotate(-66.3deg);
  }
}
@keyframes move_bot {
  100% {
    left: 50px;
    top: 150px;
    -webkit-transform: rotate(-66.2deg) rotateX(180deg);
    border-top: 130px solid #28935d;
    border-left: 100px solid transparent;
    border-right: 185px solid transparent;
  }
}
@keyframes hid_warp {
  80% {
    -webkit-transform: rotate(30deg) translateY(-200px);
  }
  100% {
    opacity: 0;
  }
}
@keyframes show_message {
  100% {
    opacity: 1;
  }
}
.top {
  width: 0;
  height: 0;
  position: absolute;
  top: 0;
  left: 0;
  left: 15px;
  display: block;
  border-bottom: 30px solid #000;
  border-left: 75px solid transparent;
  border-right: 225px solid transparent;
  -webkit-transform: rotate(4deg);
}
.after_top {
  width: 0px;
  height: 0px;
  position: absolute;
  top: 100px;
  left: 2px;
  opacity: 0;
  border-top: 130px solid #2bb673;
  border-left: 118px solid transparent;
  border-right: 185px solid transparent;
  -webkit-transform: rotate(4deg);
}
.mid {
  width: 0;
  height: 0;
  position: absolute;
  top: 40px;
  left: 0px;
  display: block;
  z-index: 11;
  border-top: 80px solid #28935d;
  border-left: 15px solid transparent;
  border-right: 300px solid transparent;
}
.bot {
  width: 0;
  height: 0;
  position: absolute;
  top: 40px;
  left: 0px;
  display: block;
  border-top: 110px solid #2bb673;
  border-left: 95px solid transparent;
  border-right: 220px solid transparent;
}
.message {
  width: 220px;
  height: 350px;
  background: #2bb673;
  position: absolute;
  top: 100px;
  left: 600px;
  opacity: 0;
  text-align: center;
}
</style>
</head>
<body>
<div class="airplane">
  <div class="top"></div>
  <div class="after_top"></div>
  <div class="mid"></div>
  <div class="bot"></div>
</div>
</body>
</html>

相關文章