⑴ 求JQUERY的圖片左右輪播的代碼,要簡單一點的謝謝
首先要定義一個索引來表示你當前輪播到第幾張圖片了
然後獲得你總共有幾張圖片 當索引跳到最後一張的時候 將其值改為0 即可
對於上一頁下一頁 邏輯與上面相同
如果當前索引為0 或者為最後一個隱藏掉這個按鈕或者賦值另一端的極值
輪播的話 寫一個定時器 第一個參數就是這個函數啦 第二個參數給1000(ms)
函數裡面就對這個index按上面的邏輯操作即可了
思路給你了 自己寫吧。。邊查邊寫 收獲會很大
⑵ 簡單的HTML+js圖片輪播
h5代碼:
<div id="wrap">
<ul id="list">
<li>10</li>
<li>9</li>
<li>8</li>
<li>7</li>
<li>6</li>
<li>5</li>
<li>4</li>
<li>3</li>
<li>2</li>
<li>1</li>
</ul>
</div>
css代碼:
<style type="text/css">
@-webkit-keyframes move{
0%{left:-500px;}
100%{left:0;}
}
#wrap{width:600px;height:130px;border:1px solid #000;position:relative;margin:100px auto;
overflow: hidden;}
#list{position:absolute;left:0;top:0;padding:0;margin:0;
-webkit-animation:5s move infinite linear;width:200%;}
#list li{list-style:none;width:120px;height:130px;border:1px solid red;background: pink;
color:#fff;text-align: center;float:left;font:normal 50px/2.5em '微軟雅黑';}
#wrap:hover #list{-webkit-animation-play-state:paused;}
</style>
(2)簡單的圖片輪播代碼擴展閱讀:
輪播圖就是一種網站在介紹自己的主打產品或重要信息的傳播方式。說的簡單點就是將承載著重要信息的幾張圖片,在網頁的某一部位進行輪流的呈現,從而做到讓瀏覽者很快的了解到網站想要表達的主要信息。以及各種新聞網站的頭版頭條都是用這種方式呈現的重要信息。
輪播圖的實現方式:例如:有5張輪播的圖片,每張圖片的寬度為1024px、高度為512px.那麼輪播的窗口大小就應該為一張圖片的尺寸,即為:1024×512。之後將這5張圖片0px水平相接組成一張寬度為:5120px,高度依然為:512px。最後將這張合成後的大圖每次向左移動1024px即可實現輪播圖。
⑶ HTML圖片輪播代碼怎麼寫
(1)<div id="butong_net_left" style="overflow:hidden;width:1000px。
(2)"> <table cellpadding="0" cellspacing="0" border="0"> <tr><td id="butong_net_left1" valign="top" align="center"> <table cellpadding="2" cellspacing="0" border="0"> <tr align="center">
⑷ HTML圖片輪播代碼怎麼寫
html部分
<divid="container">
<divclass="sections">
<divclass="section"id="section0"><h3>thisisthepage1</h3></div>
<divclass="section"id="section1"><h3>thisisthepage2</h3></div>
<divclass="section"id="section2"><h3>thisisthepage3</h3></div>
<divclass="section"id="section3"><h3>thisisthepage4</h3></div>
</div>
</div>
css部分
*{
padding:0;
margin:0;
}
html,body{
height:100%;
}
#container{
width:100%;
height:500px;
overflow:hidden;
}
.sections,.section{
height:100%;
}
#container,.sections{
position:relative;
}
.section{
background-color:#000;
background-size:cover;
background-position:50%50%;
text-align:center;
color:white;
}
#section0{
background-image:url('images/1.jpg');
}
#section1{
background-image:url('images/2.jpg');
}
#section2{
background-image:url('images/3.jpg');
}
#section3{
background-image:url('images/4.jpg');
}
.pagesli{list-style-type:none;width:10px;height:10px;border-radius:10px;background-color:white}.pagesli:hover{box-shadow:005px2pxwhite}.pagesli.active{background-color:orange;box-shadow:005px2pxorange}.pages{position:absolute;z-index:999}.pages.horizontal{left:50%;transform:translateX(-50%);bottom:5px}.pages.horizontalli{display:inline-block;margin-right:10px}.pages.horizontalli:last-child{margin-right:0}.pages.vertical{right:5px;top:50%;transform:translateY(-50%)}.pages.verticalli{margin-bottom:10px}.pages.verticalli:last-child{margin-bottom:0}
JS部分
<scriptsrc="js/jquery-1.11.0.min.js"type="text/javascript"></script>
//引入pageSwitch.min.js
<script>
$("#container").PageSwitch({
direction:'horizontal',
easing:'ease-in',
ration:1000,
autoPlay:true,
loop:'false'
});
</script>
⑸ 求圖片輪播代碼
<SCRIPT language=JavaScript>
<!--
function objSP_Article() {this.ImgUrl=""; this.LinkUrl=""; this.Title="";}
function SlidePic_Article(_id) {this.ID=_id; this.Width=0;this.Height=0; this.TimeOut=5000; this.Effect=23; this.TitleLen=0; this.PicNum=-1; this.Img=null; this.Url=null; this.Title=null; this.AllPic=new Array(); this.Add=SlidePic_Article_Add; this.Show=SlidePic_Article_Show; this.LoopShow=SlidePic_Article_LoopShow;}
function SlidePic_Article_Add(_SP) {this.AllPic[this.AllPic.length] = _SP;}
function SlidePic_Article_Show() {
if(this.AllPic[0] == null) return false;
document.write("<div align='center'><a id='Url_" + this.ID + "' href='' target='_blank'><img id='Img_" + this.ID + "' style='width:" + this.Width + "px; height:" + this.Height + "px; filter: revealTrans(ration=2,transition=23);' src='javascript:null' border='0'></a>");
if(this.TitleLen != 0) {document.write("<br><span id='Title_" + this.ID + "'></span></div>");}
else{document.write("</div>");}
this.Img = document.getElementById("Img_" + this.ID);
this.Url = document.getElementById("Url_" + this.ID);
this.Title = document.getElementById("Title_" + this.ID);
this.LoopShow();
}
function SlidePic_Article_LoopShow() {
if(this.PicNum<this.AllPic.length-1) this.PicNum++ ;
else this.PicNum=0;
this.Img.filters.revealTrans.Transition=this.Effect;
this.Img.filters.revealTrans.apply();
this.Img.src=this.AllPic[this.PicNum].ImgUrl;
this.Img.filters.revealTrans.play();
this.Url.href=this.AllPic[this.PicNum].LinkUrl;
if(this.Title) this.Title.innerHTML="<a href="+this.AllPic[this.PicNum].LinkUrl+" target='_blank'>"+this.AllPic[this.PicNum].Title+"</a>";
this.Img.timer=setTimeout(this.ID+".LoopShow()",this.TimeOut);
}
//-->
</SCRIPT>
<SCRIPT language=JavaScript>
<!--
var SlidePic_256 = new SlidePic_Article("SlidePic_256");
SlidePic_256.Width = 530;
SlidePic_256.Height = 350;
SlidePic_256.TimeOut = 5000;
SlidePic_256.Effect = 23;
SlidePic_256.TitleLen = 0;
var oSP = new objSP_Article();
oSP.ImgUrl = "http://www.ptycrc.com/img/personLeftreg.gif";
oSP.LinkUrl = "http://www.ptycrc.com/userreg.asp";
oSP.Title = " ";
SlidePic_256.Add(oSP);
var oSP = new objSP_Article();
oSP.ImgUrl = "http://www.ptycrc.com/img/companyLeftreg.gif";
oSP.LinkUrl = "http://www.ptycrc.com/com_reg.asp";
oSP.Title = " ";
SlidePic_256.Add(oSP);
var oSP = new objSP_Article();
oSP.ImgUrl = "http://www.ptycrc.com/img/logo.png";
oSP.LinkUrl = "http://www.ptycrc.com";
oSP.Title = " ";
SlidePic_256.Add(oSP);
//-->
</SCRIPT>
⑹ 求CSS圖片輪播完整代碼
以4張圖片為例:
1.基本布局:
將4張圖片左浮動橫向並排放入一個div容器內,圖片設置統一尺寸,div寬度設置4個圖片的總尺寸,然後放入相框容器div,
相框設置1個圖片的大小並設置溢出隱藏,以保證正確顯示一個照片。
2.設置動畫:
然後使用css3動畫,通過對photos進行位移,從而達到顯示不同的圖片,每次偏移一個圖片的寬度,即可顯示下一張圖片。
4張圖片,需要切換3次.
根據需要可以對各個圖片添加相應的序號和圖片簡介。
3.代碼如下:
復制代碼
1 <style>
2 #frame{position:absolute;width:300px;height:200px;overflow:hidden;border-radius:5px}
3 #dis{position:absolute;left:-50px;top:-10px;opacity:.5}
4 #dis li{display:inline-block;width:200px;height:20px;margin:0 50px;float:left;text-align:center;color:#fff;border-radius:10px;background:#000}
5 #photos img{float:left;width:300px;height:200px}
6 #photos { position: absolute;z-index:9; width: calc(300px * 4);/*---修改圖片數量的話需要修改下面的動畫參數*/ }
7 .play{ animation: ma 20s ease-out infinite alternate;}
8 @keyframes ma {
9 0%,25% { margin-left: 0px; }
10 30%,50% { margin-left: -300px; }
11 55%,75% { margin-left: -600px; }
12 80%,100% { margin-left: -900px; }
13
14 }
15 </style>
復制代碼
復制代碼
<div id="frame" >
<div id="photos" class="play">
<img src="images/1.jpg" >
<img src="images/3.jpg" >
<img src="images/4.jpg" >
<img src="images/5.jpg" >
<ul id="dis">
<li>www.scxhdzs.com#www.scxhdzs.com#111</li>
<li>22222222222222</li>
<li>33333333333333</li>
<li>44444444444444</li>
</ul>
</div>
</div>
拿走不謝!
⑺ jquery簡單自動輪播圖代碼怎麼寫
html部分 this is the page一 this is the page二 this is the page三 this is the page四 css部分 *{ padding: 0; margin: 0; } html,body{ height: 一00%; } #container { width: 一00%; height: 500px; overflow: hidden; } .sections,.section { height:一00%; } #container,.sections { position: relative; } .section { background-color: #000; background-size: cover; background-position: 50% 50%; text-align: center; color: white; } #section0 { background-image: url('images/一.jpg'); } #section一 { background-image: url('images/二.jpg'); } #section二 { background-image: url('images/三.jpg'); } #section三 { background-image: url('images/四.jpg'); } .pages li{list-style-type:none;width:一0px;height:一0px;border-radius:一0px;background-color:white}.pages li:hover{box-shadow:0 0 5px 二px white}.pages li.active{background-color:orange;box-shadow:0 0 5px 二px orange}.pages{position:absolute;z-index:999}.pages.horizontal{left:50%;transform:translateX(-50%);bottom:5px}.pages.horizontal li{display:inline-block;margin-right:一0px}.pages.horizontal li:last-child{margin-right:0}.pages.vertical{right:5px;top:50%;transform:translateY(-50%)}.pages.vertical li{margin-bottom:一0px}.pages.vertical li:last-child{margin-bottom:0} JS部分 jquery-一.一一.0.min.js" type="text/javascript"> //引入pageSwitch.min.js 如
⑻ dw圖片輪播代碼是什麼
html部分:
<div id="box" onmouseover="stop()" onmouseout="start()">
<div id="red" class="slide"></div>
<div id="green" class="slide"></div>
<div id="blue" class="slide"></div>
</div>
css部分:
#box{
width:100px;
height:100px;
border:1px solid black;
position:relative;
}
.slide{
width:100px;
height:100px;
position:absolute;
}
#box{
width:100px;
height:100px;
border:1px solid black;
position:relative;
overflow:hidden;
}
JS部分:
onload=function(){
var arr = document.getElementsByClassName("slide");
for(var i=0;i<arr.length;i++){
arr[i].style.left = i*100+"px";
}
}
function LeftMove(){
var arr = document.getElementsByClassName("slide");
for(var i=0;i<arr.length;i++){
var left = parseFloat(arr[i].style.left);
left-=2;
var width = 100;//圖片的寬度
if(left<=-width){
left=(arr.length-1)*width;//當圖片完全走出顯示框,拼接到末尾
}
arr[i].style.left = left+"px";
}
}
moveId=setInterval(LeftMove,10);//設置一個10毫秒定時器,並給自己取名
if(left<=-width){
left=(arr.length-1)*width;//當圖片完全走出顯示框,拼接到末尾
clearInterval(moveId);
}
function divInterval(){
moveId=setInterval(LeftMove,10);//設置一個10毫秒定時器
}
timeId=setInterval(divInterval,3000);//設置一個3秒的定時器。
function stop(){
clearInterval(timeId);//滑鼠停留關閉B定時器
}
function start(){
clearInterval(timeId);//重新打開一個定時前,先關閉之前定時器。
timeId=setInterval(divInterval,2000);//重啟一個定時器
}
//頁面失去焦點定時器停止
onblur = function(){
stop();
}
//頁面獲取焦點時重啟定時器
onfocus = function(){
start();
}
(8)簡單的圖片輪播代碼擴展閱讀:
代碼解析:
為整個頁面添加onload載入完成事件,當瀏覽器打開並載入完並自動執行事件中的代碼塊。這部分js代碼寫在剛才css下面即可,保持同級結構。
當頁面載入完全,三個div應該並列在一起。
接下來,需要實現將這三個div整體向左移動,使用定時器,即前面的定時器A。
為了解決當滑鼠懸停在輪播圖,輪播圖停止輪播效果,需要在box上添加滑鼠移入和移出事件。
當瀏覽器窗口切出或頁面切換到其他頁面一段時間再回來時,輪播效果會有短暫加速(隨切出時間加長而加長)。
主要是因為雖然窗口切出去了,定時器依然在執行,但頁面卻沒有將效果顯示,所以切回來後會將之前的效果顯示出來而加速輪播圖。所以添加頁面焦點事件。