纯css做的页面加载之后div回弹动画
2017-10-11 16:33
645 查看
只写了谷歌的样式,
页面一打开,div会延迟加载个小回弹动画。
以前都是用的js写,这次用了css3,感觉挺好的。
以下是简化版demo
<style>
div{
transition: all 5s;
-ms-transition: all 1s; /* Safari 和 Chrome */
-webkit-transition: all 1s; /* Safari 和 Chrome */
behavior: url(/webapps/PIE-css3/PIE.htc);
}
@-webkit-keyframes animateUp {
from, 60%, 75%, 90%, to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
from {
opacity: 0;
-webkit-transform: translate3d(0, -3000px, 0);
transform: translate3d(0, -3000px, 0);
}
60% {
opacity: 1;
-webkit-transform: translate3d(0, 28px, 0);
transform: translate3d(0, 28px, 0);
}
75% {
-webkit-transform: translate3d(0, -24px, 0);
transform: translate3d(0, -24px, 0);
}
95% {
-webkit-transform: translate3d(0, 5px, 0);
transform: translate3d(0, 5px, 0);
}
to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
@-webkit-keyframes animateLeft {
from, 60%, 75%, 90%, to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
0% {
opacity: 0;
-webkit-transform: translate3d(-3000px, 0, 0);
transform: translate3d(-3000px, 0, 0);
}
60% {
opacity: 1;
-webkit-transform: translate3d(25px, 0, 0);
transform: translate3d(25px, 0, 0);
}
75% {
-webkit-transform: translate3d(-10px, 0, 0);
transform: translate3d(-10px, 0, 0);
}
90% {
-webkit-transform: translate3d(5px, 0, 0);
transform: translate3d(5px, 0, 0);
}
to {
-webkit-transform: none;
transform: none;
}
}
.animateUp {
-webkit-animation-name: animateUp;
animation-name: animateUp;
}
.animation {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.animateLeft {
-webkit-animation-name: animateLeft;
animation-name: animateLeft;
}
</style>
<body>
<div style="width: 100%;height: 500px; position: relative;">
<div class="animateLeft animation" style="width: 200px;height: 200px; position: absolute;left: 40%;margin-left: -100px;top: 50%;margin-top: -100px; background: blue;"></div>
<div class="animateUp animation" style="width: 200px;height: 200px; position: absolute;left: 60%;margin-left: -100px;top: 50%;margin-top: -100px; background: pink;"></div>
</div>
</body>
页面一打开,div会延迟加载个小回弹动画。
以前都是用的js写,这次用了css3,感觉挺好的。
以下是简化版demo
<style>
div{
transition: all 5s;
-ms-transition: all 1s; /* Safari 和 Chrome */
-webkit-transition: all 1s; /* Safari 和 Chrome */
behavior: url(/webapps/PIE-css3/PIE.htc);
}
@-webkit-keyframes animateUp {
from, 60%, 75%, 90%, to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
from {
opacity: 0;
-webkit-transform: translate3d(0, -3000px, 0);
transform: translate3d(0, -3000px, 0);
}
60% {
opacity: 1;
-webkit-transform: translate3d(0, 28px, 0);
transform: translate3d(0, 28px, 0);
}
75% {
-webkit-transform: translate3d(0, -24px, 0);
transform: translate3d(0, -24px, 0);
}
95% {
-webkit-transform: translate3d(0, 5px, 0);
transform: translate3d(0, 5px, 0);
}
to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
@-webkit-keyframes animateLeft {
from, 60%, 75%, 90%, to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
0% {
opacity: 0;
-webkit-transform: translate3d(-3000px, 0, 0);
transform: translate3d(-3000px, 0, 0);
}
60% {
opacity: 1;
-webkit-transform: translate3d(25px, 0, 0);
transform: translate3d(25px, 0, 0);
}
75% {
-webkit-transform: translate3d(-10px, 0, 0);
transform: translate3d(-10px, 0, 0);
}
90% {
-webkit-transform: translate3d(5px, 0, 0);
transform: translate3d(5px, 0, 0);
}
to {
-webkit-transform: none;
transform: none;
}
}
.animateUp {
-webkit-animation-name: animateUp;
animation-name: animateUp;
}
.animation {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.animateLeft {
-webkit-animation-name: animateLeft;
animation-name: animateLeft;
}
</style>
<body>
<div style="width: 100%;height: 500px; position: relative;">
<div class="animateLeft animation" style="width: 200px;height: 200px; position: absolute;left: 40%;margin-left: -100px;top: 50%;margin-top: -100px; background: blue;"></div>
<div class="animateUp animation" style="width: 200px;height: 200px; position: absolute;left: 60%;margin-left: -100px;top: 50%;margin-top: -100px; background: pink;"></div>
</div>
</body>
相关文章推荐
- 多di公用一个css 按钮控制div 动态加载iframe 页面
- 纯css实现 页面加载动画
- 使用Animate.css和wow.js,实现各大网站常用的页面加载动画
- div+css页面布局的五个小技巧
- Div和CSS实现页面水平居中的方法
- DIV+CSS页面布局示例
- div嵌套页面 div加载页面 (其中获取目标页面的内容是用dwr框架连接java程序做的)
- 大学生简单网页div+css网页纯手写代码制作html静态页面切图排版
- Android实战页面内容加载动画
- div+css页面右侧底部悬浮层
- 纯css实现固定在页面底部的div层
- Android实现3D页面加载进度条动画
- 第1次尝试div+css进行两栏式页面布局就遇到了IE的3px问题
- 页面加载动画,加载完后隐藏动画
- 在禁止了页面的触摸拖动事件之后如何允许某div可以拖动
- 用div+css页面布局中的一点点记录
- iOS 应用中有页面加载gif动画,从后台进入前台时就消失了
- html DIV+CSS 页面布局
- Div+CSS布局入门教程之三:页面顶部制作之一
- 用css+div进行页面布局