animate.css是一个不错CSS3预设动画库,是很好的CSS3动画学习资源,下面来剖析下bounce效果的实现原理,在此基础上实现自己的CSS动画。
先从animate.css把bounce效果单独移出来,暂不考虑针对不同的浏览器的支持,测试浏览器为chrome,看一下效果。
<!DOCTYPE html>
<html>
<head>
<title>bounce-source</title>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, minimal-ui" />
<style type="text/css">
html {
font: 100%/1.5 "Roboto", Verdana, sans-serif;
color: #3d464d;
background-color: #fff;
-webkit-font-smoothing: antialiased;
width: 100%;
overflow: hidden-x;
text-align: center;
}
.font-style{
color: #f35626;
background-image: -webkit-linear-gradient(92deg,#f35626,#feab3a);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
-webkit-animation: hue 10s infinite linear;
}
h1{
margin-bottom: 1.5rem;
font-size: 6rem;
font-weight: 100;
line-height: 1;
letter-spacing: -.05em;
}
@-webkit-keyframes hue {
from {
-webkit-filter: hue-rotate(0deg);
}
to {
-webkit-filter: hue-rotate(-360deg);
}
}
</style>
<style type="text/css">
.animated {
animation-duration: 1s;
animation-fill-mode: both;
}
.animated.infinite {
animation-iteration-count: infinite;
}
.bounce {
animation-name: bounce;
transform-origin: center bottom;