


nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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淘宝商城多格焦点图效果
- 说明:
- 来源:淘宝商城 代码整理:54173BLOG 首发:懒人图库
- *尊重他人劳动成果,转载请自觉注明出处!注:此代码仅供学习交流,请勿用于商业用途。
- {download}
- {content}
- {google_729x90}
I downloaded this code online and can only understand the following parts of , Although some of the above have comments and are very clear, but what I know more is, how to understand these codes? Or should I just memorize it by rote?
Reply to discussion (solution)
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;}
is the special effect of JavaScript.
The example you posted quoted the js library--jquery.
The poster can learn from it
http://www.w3school.com.cn/jquery/index.asp
Thank you for your help, the website explains it in detail!

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
