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