jquery实现的网页层动画效果,网页打开后加载jQuery,一个动画层展开,内容渐显出来。 为解决一些网页特效运行后不能显示效果(例如:jQuery则需要刷新)问题,烈火特别新增网页版演示。 点击查看:网页特效 运行演示: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>一个网页层动画效果,jquery实现</title> <meta http-equiv="content-type" content="text/html; charset=gbk"> <!-- Site styles --> <style type="text/css"> #demo div { overflow: hidden; } #demo { height: 40em; left: 50%; margin: -25em 0 0 -20em; position: absolute; top: 50%; width: 40em; } #intro { height: 5em; opacity: 1; padding: 0 2em; position: relative; } #box { border-radius: 4px; border: 2px solid #333; padding: 0 2em; position: relative; } .no-js #box { background: #22346F; } .js #box { border-color: white; padding: 0; } .js p, .js #intro h2 { opacity: 0; position: relative; } #box h2 { color: #fafafa; top: -2.3em; position: relative; } </style> <script type="text/javascript" src="http://www.veryhuo.com/uploads/common/js/jquery-1.5.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#intro h2").css({ bottom: '-1.5em', opacity: 1 }); $("#box").css({ background: '#444', 'border-color': '#BBB', height: 0, width: 0 }); $("p").css({ opacity: 0, position: 'relative', left: '-3em' }); $("p.b, p.copyright").css({ left: '3em' }); window.myRunloop = jQuery.runloop(); myRunloop.addKey('10%', function(){ $("#box").animate( { width:'350px', paddingLeft:'2em', paddingRight:'2em' }, { duration:1000, queue:false } ) }); myRunloop.addMap({ '15%': function(){ $("#intro h2").animate( { bottom:'0' }, { duration:1000, queue:false } )}, '30%': function(){ myRunloop.pause(); var name = window.prompt('What’s your first name?'); name = (name == null || name.replace(/[^a-zA-Z]/g, '') == "") ? "You" : name.replace(/[^a-zA-Z]/g, ''); $("#name").text(name); $("#drowning").text($("#intro h2").text()); myRunloop.play(); }, '40%': function(){ $("#box").animate({ height:'50%' }, { duration:1500, queue:false } ) }, '50%': function(){ $("#intro h2").animate({ bottom:'-2.3em' }, { duration:1000, queue:false } ); $("#box h2").animate({ top:0 }, { duration:1000, queue:false } ); }, '55%': function(){ $("p.a").animate( { opacity:1, left:0 }, { duration:500, queue:false } ); }, '70%': function(){ $("p.b").animate( { opacity:1, left:0 }, { duration:500, queue:false } ); }, '85%': function(){ $("p.c").animate( { opacity:1, left:0 }, { duration:500, queue:false } ); }, '100%': function(){ $("p.copyright").animate( { opacity:1, left:0 }, { duration:650, queue:false } ); } }); myRunloop.addKey('50%', function(){ if(window.console) console.log('First call at 50%'); }); myRunloop.addKey('50%', function(){ if(window.console) console.log('Second call at 50%'); }); function optionalCallback(){ if(window.console) console.log('Runloop done!'); }; myRunloop.play(10000, optionalCallback); }); </script> </head> <body> <!-- Demo area --> <div id="demo"> <div id="intro"> <h2>Hello, <span id="name">You</span></h2> </div> <div id="box"> <h2 id="drowning">Hello, You</h2> <p class="a">Sunflowa Media - Green,Reliable,Funny Web Design. </p> <p class="b">I am a freelance web designer & graphic designer based in Shanghai, CN. I make Green Environment Protection website, accessible websites that are easy to use and easy for our life.</p> </div> </div> <!-- / demo area --> </body> </html><br /><center>如不能显示效果,请按Ctrl+F5刷新本页,更多网页代码:<a href='http://www.veryhuo.com/' target='_blank'>http://www.veryhuo.com/</a></center>提示:可修改后代码再运行! 文章导航 仿淘宝网产品列表的收起展开、隐藏显示代码纯CSS无图实现阴影和小三角提示框代码