web前端|H5教程
Webkit,HTML5,web
web前端-H5教程
HTML5和Webkit在一起会实现什么样的动画呢?本文给大家分享一段实例代码给大家介绍基于HTML5+Webkit实现树叶飘落动画效果,需要的朋友参考下吧,希望能帮组到大家。
app扎金花源码,vscode的搜索搜索不到,ubuntu 16迅雷,tomcat单独布置项目,java爬虫私活,mac php安装gd库,成都网络推广seo怎样优化,博客特效网站模板,中国电影网 的网页模板lzw
实现如图所示的东西效果(落叶下落):
安卓播放音乐源码,vscode关键字加粗,ubuntu 服务开启,tomcat8.5端口,网页智能爬虫,php 伪原创代码,宜昌服装seo推广哪里好,目录网站程序源码,淘宝系统免费模板lzw
erp框架源码,vscode格式化插件配置,ubuntu备份tar,tomcat配置视频播放,python爬虫 介绍,php钩子的作用,什么是seo平台关键词,网站功能演示lzw
html代码:
这是基于webkit的落叶动画
css代码:body{ background-color: #4E4226;}#container { position: relative; height: 700px; width: 500px; margin: 10px auto; overflow: hidden; border: 4px solid #5C090A; background: #4E4226 url(images/backgroundLeaves.jpg) no-repeat top left;}#leafContainer { position: absolute; width: 100%; height: 100%;}#message{ position: absolute; top: 160px; width: 100%; height: 300px; background:transparent url(images/textBackground.jpg) repeat-x center; color: #5C090A; font-size: 220%; font-family: Georgia; text-align: center; padding: 20px 10px; -webkit-box-sizing: border-box; -webkit-background-size: 100% 100%; z-index: 1;}em { font-weight: bold; font-style: normal;}#leafContainer > p { position: absolute; width: 100px; height: 100px; -webkit-animation-iteration-count: infinite; -webkit-animation-direction: normal; -webkit-animation-timing-function: linear;}#leafContainer > p > img {position: absolute;width: 100px;height: 100px;-webkit-animation-iteration-count: infinite;-webkit-animation-direction: alternate;-webkit-animation-timing-function: ease-in-out;-webkit-transform-origin: 50% -100%;}@-webkit-keyframes fade{ 0% { opacity: 1; } 95% { opacity: 1; } 100% { opacity: 0; }}@-webkit-keyframes drop{ 0% { -webkit-transform: translate(0px, -50px); } 100% { -webkit-transform: translate(0px, 650px); }}@-webkit-keyframes clockwiseSpin{ 0% { -webkit-transform: rotate(-50deg); } 100% { -webkit-transform: rotate(50deg); }}@-webkit-keyframes counterclockwiseSpinAndFlip { 0% { -webkit-transform: scale(-1, 1) rotate(50deg); } 100% { -webkit-transform: scale(-1, 1) rotate(-50deg); }}js代码:const NUMBER_OF_LEAVES = 30;function init(){ var container = document.getElementById(leafContainer); for (var i = 0; i < NUMBER_OF_LEAVES; i++) { container.appendChild(createALeaf()); }}function randomInteger(low, high){ return low + Math.floor(Math.random() * (high - low));}function randomFloat(low, high){ return low + Math.random() * (high - low);}function pixelValue(value){ return value + px;}function durationValue(value){ return value + s;}function createALeaf(){ var leafp = document.createElement(p); leafp.style.top = "-100px"; leafp.style.left = pixelValue(randomInteger(0, 500)); leafp.style.webkitAnimationName = fade, drop; var fadeAndDropDuration = durationValue(randomFloat(5, 11)); leafp.style.webkitAnimationDuration = fadeAndDropDuration + , + fadeAndDropDuration; var leafDelay = durationValue(randomFloat(0, 5)); leafp.style.webkitAnimationDelay = leafDelay + , + leafDelay; var image = document.createElement(img); image.src = images/realLeaf + randomInteger(1, 5) + .jpg; var spinAnimationName = (Math.random() < 0.5) ? clockwiseSpin : counterclockwiseSpinAndFlip; image.style.webkitAnimationName = spinAnimationName; var spinDuration = durationValue(randomFloat(4, 8)); image.style.webkitAnimationDuration = spinDuration; leafp.appendChild(image); return leafp;}window.addEventListener(load, init, false);
PS:下面看下html5 canvas处理连续帧图片,下面的代码基于IE8以上
使用Html5实现树叶飘落的效果
jQuery+CSS3实现树叶飘落特效_jquery
逼真的HTML5树叶飘落动画_html5教学技巧