滚动页面,然后再执行CSS3 动画
2014-12-28 10:55
225 查看
<!doctype html> <html> <head> <meta charset="utf-8"> <title>动态CSS3动画</title> <style> * {margin:0; border:0; padding:0;} body {width:100%; height:2000px;} #div1 {width:100px; height:100px; background-color:#000; position:relative;} .ani {animation:myfirst 2s linear forwards; -webkit-animation:myfirst 2s linear forwards;} @keyframes myfirst {from {left:0; top:0} to {left:400px; top:400px;}} @-webkit-keyframes myfirst {from {left:0; top:0} to {left:400px; top:400px;}} </style> <script> window.onload = function (){<span style="white-space:pre"> </span> <span style="white-space:pre"> </span>window.onscroll = function (){ <span style="white-space:pre"> </span>//两种方法:1、通过style.cssText写入样式;2、通过className添加类。 <span style="white-space:pre"> </span>//document.getElementById("div1").style.cssText = "animation:myfirst 2s linear forwards; -webkit-animation:myfirst 2s linear forwards"; <span style="white-space:pre"> </span>document.getElementById("div1").className = "ani"; <span style="white-space:pre"> </span>} } </script> </head> <body> <div id="div1"></div> <script> </script> </body> </html>
相关文章推荐
- 使用CSS3 will-change提高页面滚动、动画等渲染性能
- AOS – 另外一个独特的页面滚动动画库(CSS3)
- jQuery.smoove — jQuery和CSS3炫酷滚动页面内容元素动画特效插件
- AOS – 另外一个独特的页面滚动动画库(CSS3)
- PageSlider中CSS3动画在除首屏之外先加载页面后执行动画的问题
- 【特效】页面滚动到相应位置运行css3动画
- jQuery和CSS3炫酷滚动页面内容元素动画特效
- 基于jQ+CSS3页面滚动内容元素动画特效
- jquery防止重复执行动画避免页面混乱
- HTML5+CSS3构建同页面表单间的动画切换
- HTML5+CSS3构建同页面表单间的动画切换
- jquery的动画效果animate附加一个滚动回到页面的例子
- WOW.js – 在页面滚动时展现动感的元素动画效果
- HTML5+CSS3构建同页面表单间的动画切换
- JQM1.4 脚本执行页面跳转动画,dialog打开动画
- js判断页面滚动到底部的时候,可以执行一些操作
- CSS3动画animation实现云彩向左滚动
- HTML5+CSS3构建同页面表单间的动画切换
- CSS3制作动画加载页面
- 超棒的CSS3动画页面过渡效果