杂乱教程 | 2020年05月12日16时03分45秒 | 评论:0
网站背景图,多张可自行设置图片,自动切换,有喜欢的小伙伴可以看看~
本套代码需要用到jquery-1.2.6.min.js,大家可以在百度上下载到自己本地,jquery-1.2.6.min.js js需要放在head里;
<!--------------------------------------动态背景--------------------------------> <!--将本段代码放入网站的head标签中--> <script type="text/javascript"> function slideSwitch() { var $active = $('#slideshow IMG.active'); if ( $active.length == 0 ) $active = $('#slideshow IMG:last'); var $next = $active.next().length ? $active.next() : $('#slideshow IMG:first'); $active.addClass('last-active'); $next.CSS({opacity: 0.0}) .addClass('active') .animate({opacity: 1.0}, 1000, function() { $active.removeClass('active last-active'); }); } $(function() { setInterval( "slideSwitch()", 5000 ); }); </script> <!--------------------------------------动态背景-------------------------------->
<!--------------------------------------动态背景--------------------------------> <div id="slideshow"> <img src="图片地址" alt="" class="active"> <img src="图片地址" alt="" /> ... <!--想展示多少条图片 就设置多少条--> </div> <!--------------------------------------动态背景-------------------------------->
css代码:
#slideshow { position: relative; height: 100%; z-index: -1; } #slideshow IMG { position: absolute; top: 0; left: 0; z-index: 8; opacity: 0.0; } #slideshow IMG.active { z-index: 10; opacity: 1.0; } #slideshow IMG.last-active { z-index: 9; } #slideshow img { min-height: 100%; min-width: 1024px; width: 100%; height: auto; position: fixed; top: 0; left: 0; }
相关文章
网友点评
本文暂无评论 - 欢迎您
⎛⎝爱站云⎠⎞
AiZhanCloud.Com