Heim  >  Artikel  >  Web-Frontend  >  虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose

虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:12:05962Durchsuche

nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



{title}_懒人图库





<script></script>
<script> <br /> $(function() { <br /> var sWidth = $("#focus").width(); //获取焦点图的宽度(显示面积) <br /> var len = $("#focus ul li").length; //获取焦点图个数 <br /> var index = 0; <br /> var picTimer; <br /> <br /> //以下代码添加数字按钮和按钮后的半透明长条 <br /> var btn = "<div class='btnBg'><div class='btn'>"; <br /> for(var i=0; i < len; i++) { <br /> btn += "<span>" + (i+1) + ""; <br /> } <br /> btn += "" <br /> $("#focus").append(btn); <br /> $("#focus .btnBg").css("opacity",0.5); <br /> <br /> //为数字按钮添加鼠标滑入事件,以显示相应的内容 <br /> $("#focus .btn span").mouseenter(function() { <br /> index = $("#focus .btn span").index(this); <br /> showPics(index); <br /> }).eq(0).trigger("mouseenter"); <br /> <br /> //本例为左右滚动,即所有li元素都是在同一排向左浮动,所以这里需要计算出外围ul元素的宽度 <br /> $("#focus ul").css("width",sWidth * (len + 1)); <br /> <br /> //鼠标滑入某li中的某div里,调整其同辈div元素的透明度,由于li的背景为黑色,所以会有变暗的效果 <br /> $("#focus ul li div").hover(function() { <br /> $(this).siblings().css("opacity",0.7); <br /> },function() { <br /> $("#focus ul li div").css("opacity",1); <br /> }); <br /> <br /> //鼠标滑上焦点图时停止自动播放,滑出时开始自动播放 <br /> $("#focus").hover(function() { <br /> clearInterval(picTimer); <br /> },function() { <br /> picTimer = setInterval(function() { <br /> if(index == len) { //如果索引值等于li元素个数,说明最后一张图播放完毕,接下来要显示第一张图,即调用showFirPic(),然后将索引值清零 <br /> showFirPic(); <br /> index = 0; <br /> } else { //如果索引值不等于li元素个数,按普通状态切换,调用showPics() <br /> showPics(index); <br /> } <br /> index++; <br /> },3000); //此3000代表自动播放的间隔,单位:毫秒 <br /> }).trigger("mouseleave"); <br /> <br /> //显示图片函数,根据接收的index值显示相应的内容 <br /> function showPics(index) { //普通切换 <br /> var nowLeft = -index*sWidth; //根据index值计算ul元素的left值 <br /> $("#focus ul").stop(true,false).animate({"left":nowLeft},500); //通过animate()调整ul元素滚动到计算出的position <br /> $("#focus .btn span").removeClass("on").eq(index).addClass("on"); //为当前的按钮切换到选中的效果 <br /> } <br /> <br /> function showFirPic() { //最后一张图自动切换到第一张图时专用 <br /> $("#focus ul").append($("#focus ul li:first").clone()); <br /> var nowLeft = -len*sWidth; //通过li元素个数计算ul元素的left值,也就是最后一个li元素的右边 <br /> $("#focus ul").stop(true,false).animate({"left":nowLeft},500,function() { <br /> //通过callback,在动画结束后把ul元素重新定位到起点,然后删除最后一个复制过去的元素 <br /> $("#focus ul").css("left","0"); <br /> $("#focus ul li:last").remove(); <br /> }); <br /> $("#focus .btn span").removeClass("on").eq(0).addClass("on"); //为第一个按钮添加选中的效果 <br /> } <br /> }); <br /> <br /> </script>




jQuery淘宝商城多格焦点图效果






  • 虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose


    虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose

    虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose

    虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose




  • 虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose




  • 虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose


    虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose

    虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose

    虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose




  • 虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose

    虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose

    虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose

    虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose





  • 虽然在网上下载了一些焦点图的代码来研究,但还是不太懂,能请教下高手有什么有什么公式的吗?_html/css_WEB-ITnose






说明:

来源:淘宝商城  代码整理:54173BLOG  首发:懒人图库

*尊重他人劳动成果,转载请自觉注明出处!注:此代码仅供学习交流,请勿用于商业用途。

{download}

{content}

{google_729x90}






我在网上下了这段代码,只看得懂以下的,的以上的虽然有些有注释也说的很明白,但是我更像知道的是,这些代码该怎么理解?还是要死记硬背掉就好了?


回复讨论(解决方案)

style type="text/css">
* {margin:0; padding:0;}
body {font-size:12px; color:#222; font-family:Verdana,Arial,Helvetica,sans-serif; background:#f0f0f0;}
.clearfix:after {content: "."; display: block; height: 0; clear: both; visibility: hidden;}
.clearfix {zoom:1;}
ul,li {list-style:none;}
img {border:0;}

.wrapper {width:600px; margin:0 auto; padding-bottom:50px;}
.ad {width:468px; margin:10px auto 0;}
.ad li {padding-top:5px;}

h1 {height:50px; line-height:50px; font-size:22px; font-weight:normal; font-family:"Microsoft YaHei",SimHei;}

.shuoming {margin-top:20px; border:1px solid #ccc; padding-bottom:10px;}
.shuoming dt {height:30px; line-height:30px; font-weight:bold; text-indent:10px;}
.shuoming dd {line-height:20px; padding:5px 20px;}

.wrapper {width:780px;}
/* tmall focus */
#focus {width:780px; height:380px; overflow:hidden; position:relative;}
#focus ul {height:380px; position:absolute;}
#focus ul li {float:left; width:780px; height:380px; overflow:hidden; position:relative; background:#000;}
#focus ul li div {position:absolute; overflow:hidden;}
#focus .btnBg {position:absolute; width:780px; height:40px; left:0; bottom:0; background:#000;}
#focus .btn {position:absolute; width:770px; height:24px; left:0; bottom:8px; padding-left:10px;}
#focus .btn span {display:inline-block; _display:inline; _zoom:1; width:24px; height:24px; line-height:24px; text-align:center; font-size:20px; font-family:"Microsoft YaHei",SimHei; margin-right:10px; cursor:pointer; color:#fff;}
#focus .btn span.on {background:#000; color:#fcc;}


<script></script>
<script> <br /> $(function() { <br /> 还有请问下,这段是用来干嘛的?一点都看不懂 ... <br /> <br /> 这段代码在页面起什么作用吗?我好想没看到里面的字样出现在页面上<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br /> <html xmlns="http://www.w3.org/1999/xhtml"> <br /> <head> <br /> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <br /> <title>{title}_懒人图库 <br /> <meta name="keywords" content="jquery特效,jquery焦点图,jquery图片轮换,jquery相册效果,焦点图实例,淘宝焦点图代码下载,{keyword},JS广告代码,JS特效代码" /> <br /> <meta name="description" content="此代码内容为{title},属于站长常用代码,更多{keyword}代码请访问懒人图库JS代码频道。" /> <br /> <br /> <br /> </script>

就是javascript的特效,
你贴的例子中 引用了js库--jquery。
楼主可以学下
http://www.w3school.com.cn/jquery/index.asp

谢谢您的帮助,网站上说的很详细!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn