电影式滑动效果加自动轮播





jQuery有缩微图和介绍的图片切换




/*html部分*/
电影
css分两部分:(1) @charset "gb2312"; body,div,hr,blockquote,ul,ol,li,table,th,td,dl,dt,dd,h1,h2,h3,h4,h5,h6,pre,form,input,button,select,textarea,fieldset,legend{margin:0;padding:0} body{font-size:12px;color:#333; background-color:#1d262c;font-family:Tahoma,Geneva,sans-serif,'宋体';} h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal} .clearfix{*zoom:1} .clearfix:after{display:block;clear:both;content:".";visibility:hidden;height:0} *+html img{-ms-interpolation-mode:bicubic} .clearboth{ clear:both;} ul,ol{list-style:none} fieldset,img{border:0} address,cite,dfn,em,var{font-style:normal} strong,.fcu{font-weight:bold} table{border-collapse:collapse;border-spacing:0} button,.fhand{cursor:pointer} button,input,select,textarea{font-size:100%;} html{zoom:expression(function(ele){ele.style.zoom="1";document.execCommand("BackgroundImageCache",false,true)}(this))} /*通用*/ .navbox_{width:960px;margin:0 auto; overflow:hidden;zoom:1} .navbox{width:960px;margin:0 auto; overflow:hidden;zoom:1; margin-top:8px;} .f_l{ float:left;} .f_r{ float:right;} .margintop{margin-top:8px;} .paddingtop{padding-top:8px;} a{color:#383838; text-decoration: none;} a:hover{color:#c00; text-decoration:underline;} (2): /*slider*/ #slider{width:100%;background-color:#000; padding-top:8px;margin-top: 100px;} .slider_box{width:960px; margin:0 auto;height: 338px;overflow: hidden;position: relative;} .silder_tip{width: 92px;height: 92px;overflow: hidden;position: absolute;top: 0;right: 0;z-index:1; text-indent:-999px;background:url(../images/tip-tt.gif) no-repeat;} #movie_tip{background-position: -93px 0;} .silder_con{height:270px;overflow: hidden;position: absolute;} .silder_panel{width:960px;height:270px;overflow: hidden;float: left;position: relative;background: #111;} .silder_panel img{width: 690px;height: 270px;display: block;overflow: hidden;} .silder_intro{width: 210px;height: 270px;line-height: 20px;overflow: hidden;color: #999;padding: 0 40px 0 0;} .silder_intro h3{padding:10px 0;height:50px;color:#7acf39;line-height: 30px;overflow: hidden;} .silder_intro h3 strong{font-family: "宋体";font-size: 24px;height:30px;overflow: hidden;font-weight: normal;display: block;} .silder_intro h3 strong a{ color: #fff; font-weight:bold;} .silder_intro ul{height: 60px;overflow: hidden;} .silder_intro li{height: 20px;overflow: hidden;color:#787878;} .silder_intro li a{color:#787878; margin:0 6px;} .silder_intro span{ margin: 0 10px 0 0;} .silder_intro p{height:72px;overflow: hidden;color:#787878; margin-top:10px; line-height:18px;} .silder_play{display: block;width:136px;height:30px;overflow: hidden;text-indent: -999px;position: absolute;bottom: 13px;right: 45px;background: url(../img/silder-play.png) 0 -30px no-repeat;} .silder_play:hover{ background-position: 0 0;} .silder_nav{width:960px;height:58px;margin: 0 auto;bottom: 0;position: absolute;overflow: hidden;} .silder_nav li{float: left;padding:0px;border:1px solid #fff; margin:2px;} .silder_nav li.current{border:3px solid #7acf39; margin:0 4px;} .silder_nav li,.silder_nav img{display: block;width:112px;height:48px;overflow: hidden;} .slider_box a.prev,.slider_box a.next{display: block;width:45px;height:100px;overflow:hidden;text-indent: -999px;position: absolute;cursor: pointer;margin: 85px 0 0 0;background: url(../img/silder_btn.gif) no-repeat;} .slider_box a.prev{left:0;background-position: left 0;} .slider_box a.next{right:0;background-position: right 0;} .silderBox{height:8px; line-height:8px;} jQuery部分: $(function(){ var sWidth = $("#slider_name").width(); var len = $("#slider_name .silder_panel").length; var index = 0; var picTimer; var btn = ""; $("#slider_name").append(btn); $("#slider_name .silder_nav li").css({"opacity":"0.6","filter":"alpha(opacity=60)"}).mouseenter(function() { index = $("#slider_name .silder_nav li").index(this); showPics(index); }).eq(0).trigger("mouseenter"); $("#slider_name .prev,#slider_name .next").css({"opacity":"0.2","filter":"alpha(opacity=20)"}).hover(function(){ $(this).stop(true,false).animate({"opacity":"0.6","filter":"alpha(opacity=60)"},300); },function() { $(this).stop(true,false).animate({"opacity":"0.2","filter":"alpha(opacity=20)"},300); }); // Prev $("#slider_name .prev").click(function() { index -= 1; if(index == -1) {index = len - 1;} showPics(index); }); // Next $("#slider_name .next").click(function() { index += 1; if(index == len) {index = 0;} showPics(index); }); // $("#slider_name .silder_con").css("width",sWidth * (len)); // mouse $("#slider_name").hover(function() { clearInterval(picTimer); },function() { picTimer = setInterval(function() { showPics(index); index++; if(index == len) {index = 0;} },3000); }).trigger("mouseleave"); // showPics function showPics(index) { var nowLeft = -index*sWidth; $("#slider_name .silder_con").stop(true,false).animate({"left":nowLeft},300); $("#slider_name .silder_nav li").removeClass("current").eq(index).addClass("current"); $("#slider_name .silder_nav li").stop(true,false).animate({"opacity":"0.5"},300).eq(index).stop(true,false).animate({"opacity":"1"},300); } });

你可能感兴趣的:(电影式滑动效果加自动轮播)