เอฟเฟกต์ Bounce Out Up
องค์ประกอบเด้งขึ้นเล็กน้อย แล้วบินขึ้นไปด้านบนจนหาย ใช้สำหรับ dismiss element แบบมีชีวิตชีวา
โค้ดตัวอย่างสมบูรณ์
<html>
<head>
<style>
.animated {
background-image: url(/css/images/logo.png);
background-repeat: no-repeat;
background-position: left top;
padding-top: 95px;
margin-bottom: 60px;
-webkit-animation-duration: 10s;
animation-duration: 10s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes bounceOutUp {
0% { -webkit-transform: translateY(0); }
20% { opacity: 1; -webkit-transform: translateY(20px); }
100% { opacity: 0; -webkit-transform: translateY(-2000px); }
}
@keyframes bounceOutUp {
0% { transform: translateY(0); }
20% { opacity: 1; transform: translateY(20px); }
100% { opacity: 0; transform: translateY(-2000px); }
}
.bounceOutUp {
-webkit-animation-name: bounceOutUp;
animation-name: bounceOutUp;
}
</style>
</head>
<body>
<div id="animated-example" class="animated bounceOutUp"></div>
<button onclick="myFunction()">Reload page</button>
<script>
function myFunction() { location.reload(); }
</script>
</body>
</html>
การวิเคราะห์ Keyframes
| ขั้นตอน | Transform Y | Opacity | พฤติกรรม |
|---|---|---|---|
| 0% | 0 | 1 | ตำแหน่งปกติ |
| 20% | +20px (ลงเล็กน้อย) | 1 | กดลงสร้างแรงเด้ง |
| 100% | -2000px (บนจอ) | 0 | เด้งขึ้นบินหาย |
ความแตกต่าง Bounce Out Up vs Fade Out Up Big
- Bounce Out Up: มีการ "กดลง" ก่อนเด้งขึ้น (20% translateY(20px))
- Fade Out Up Big: ไม่มีการกดลง บินขึ้นตรงๆ ตลอด