溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

如何使用css3實(shí)現(xiàn)圖片輪播和按鈕

發(fā)布時(shí)間:2022-03-01 11:12:14 來源:億速云 閱讀:155 作者:小新 欄目:web開發(fā)

這篇文章將為大家詳細(xì)講解有關(guān)如何使用css3實(shí)現(xiàn)圖片輪播和按鈕,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

  CSS代碼:

  #second_div{

  margin-top: 160px;

  }

  。img_box{

  overflow: hidden;

  width:100%;

  height:420px;

  border:1px solid;

  position:relative;

  }

  。img_box img{

  width:100%;

  position:absolute;

  }

  。ul5{

  list-style: none;

  position:absolute;

  left:580px;

  top:565px;

  }

  。ul5 li{

  float:left;

  margin-left:20px;

  width:40px;

  height:5px;

  border:0px;

  background:lawngreen;

  }

  。d1,.d2{

  width:50px;

  height:60px;

  background-color: rgba(10,10,10,0.5);

  text-align: center;

  font-size:26px;

  font-weight: 800px;

  line-height:60px;

  cursor: pointer;

  }

  。d1{

  position:absolute;

  top:373px;

  left:25px;

  }

  。d2{

  position:absolute;

  top:373px;

  left:1445px;

  }

  HTML遇新是直朋能到分覽代碼:

  js代碼遇新是直朋能到:

  $("#ss")。click(function(){var new_li=$("

  "+ $("#skuang")。val() +"");

  $("#d1 ul")。append(new_li);

  $("#d1")。hide();

  $("#skuang")。val("");

  })

  $("#skuang")。focus(function(){

  $("#d1")。css("display","block");

  });

  $("#skuang")。blur();

  $("#qingch")。click(function(){

  $("#d1 li:gt(0)")。remove();

  $("#d1")。hide();

  });//輪播圖

  var img=$(".img_box img");var li=$(".ul5 li");var divW=$(".img_box")。width();var len=$(".img_box img")。length;

  img.css("left",divW);

  img.eq(0)。css("left",0);

  li.eq(0)。css("background","red");var index=0;var next=0;functionshow(){

  next++;if(next==len){

  next=0;

  }

  img.eq(next)。css("left",divW);

  img.eq(index)。animate();

  img.eq(next)。animate();

  li.eq(next)。css("background","red");

  li.eq(index)。css("background","lawngreen");

  index=next;

  }

  t=setInterval(show,2000);functionshow1(){

  next--;if(next==-1){

  next=len-1;

  }

  img.eq(next)。css("left",-divW);

  img.eq(index)。animate();

  img.eq(next)。animate();

  li.eq(next)。css("background","red");

  li.eq(index)。css("background","lawngreen");

  index=next;         比抖朋要插支一圈不者地

  }

  img.hover(function(){

  clearInterval(t);    遇新是直朋能到分覽支體調(diào)

  },function(){

  t=setInterval(show,2000);

  })//左右按鈕

  $(".d2")。mousedown(function(){

  clearInterval(t);

  show();

  })

  $(".d2")。mousedown(function(){

  t=setInterval(show,2000);

  })

  $(".d1")。mousedown(function(){

  clearInterval(t);

  show1();

  })

  $(".d1")。mousedown(function(){

  t=setInterval(show,2000);

  })//小白點(diǎn) 點(diǎn)擊

  li.mousedown(function(){

  num=$(this)。index();if(num==next){return;

  }else if(num

  clearInterval(t);

  img.eq(num)。css("left",-divW);

  img.eq(index)。animate();

  img.eq(num)。animate();

  li.eq(num)。css("background","red");

  li.eq(index)。css("background","lawngreen");

  index=num;

  next=num;

  }else if(num>next){

  clearInterval(t);

  img.eq(num)。css("left",divW);

  img.eq(index)。animate();

  img.eq(num)。animate();

  li.eq(num)。css("background","red");

  li.eq(index)。css("background","lawngreen");

  index=num;

  next=num;

  }

  })

  li.mouseup(function(){

  t=setInterval(show,2000);

  })

  })

關(guān)于“如何使用css3實(shí)現(xiàn)圖片輪播和按鈕”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI