求首页js轮播图代码

JavaScript028

求首页js轮播图代码,第1张

<!DOCTYPE html>

<html>

<head>

  <meta charset="UTF-8">

  <title>query焦点轮播图</title>

  <style type="text/css">

      *{ margin: 0padding: 0text-decoration: none}

      body { padding: 20px}

      #container { width: 600pxheight: 400pxborder: 3px solid #333overflow: hiddenposition: relative}

      #list { width: 4200pxheight: 400pxposition: absolutez-index: 1}

      #list img { float: left}

      #buttons { position: absoluteheight: 10pxwidth: 100pxz-index: 2bottom: 20pxleft: 250px}

      #buttons span { cursor: pointerfloat: leftborder: 1px solid #fffwidth: 10pxheight: 10pxborder-radius: 50%background: #333margin-right: 5px}

      #buttons .on {  background: orangered}

      .arrow { cursor: pointerdisplay: noneline-height: 39pxtext-align: centerfont-size: 36pxfont-weight: boldwidth: 40pxheight: 40px position: absolutez-index: 2top: 180pxbackground-color: RGBA(0,0,0,.3)color: #fff}

      .arrow:hover { background-color: RGBA(0,0,0,.7)}

      #container:hover .arrow { display: block}

      #prev { left: 20px}

      #next { right: 20px}

  </style>

  <script type="text/javascript" src="js/jquery.1.10.2.js"></script>

  <script type="text/javascript">

      $(function () {

          var container = $('#container')

          var list = $('#list')

          var buttons = $('#buttons span')

          var prev = $('#prev')

          var next = $('#next')

          var index = 1

          var len = 5

          var interval = 3000

          var timer

          function animate (offset) {

              var left = parseInt(list.css('left')) + offset

              if (offset>0) {

                  offset = '+=' + offset

              }

              else {

                  offset = '-=' + Math.abs(offset)

              }

              list.animate({'left': offset}, 300, function () {

                  if(left >-200){

                      list.css('left', -600 * len)

                  }

                  if(left <(-600 * len)) {

                      list.css('left', -600)

                  }

              })

          }

          function showButton() {

              buttons.eq(index-1).addClass('on').siblings().removeClass('on')

          }

          function play() {

              timer = setTimeout(function () {

                  next.trigger('click')

                  play()

              }, interval)

          }

          function stop() {

              clearTimeout(timer)

          }

          next.bind('click', function () {

              if (list.is(':animated')) {

                  return

              }

              if (index == 5) {

                  index = 1

              }

              else {

                  index += 1

              }

              animate(-600)

              showButton()

          })

          prev.bind('click', function () {

              if (list.is(':animated')) {

                  return

              }

              if (index == 1) {

                  index = 5

              }

              else {

                  index -= 1

              }

              animate(600)

              showButton()

          })

          buttons.each(function () {

               $(this).bind('click', function () {

                   if (list.is(':animated') || $(this).attr('class')=='on') {

                       return

                   }

                   var myIndex = parseInt($(this).attr('index'))

                   var offset = -600 * (myIndex - index)

                   animate(offset)

                   index = myIndex

                   showButton()

               })

          })

          container.hover(stop, play)//鼠标移入停止轮播

          play()

      })

  </script>

</head>

<body>

<div id="container">

  <div id="list" style="left: -600px">

      <img src="img/5.jpg" alt="1"/>

      <img src="img/1.jpg" alt="1"/>

      <img src="img/2.jpg" alt="2"/>

      <img src="img/3.jpg" alt="3"/>

      <img src="img/4.jpg" alt="4"/>

      <img src="img/5.jpg" alt="5"/>

      <img src="img/1.jpg" alt="5"/>

  </div>

  <div id="buttons">

      <span index="1" class="on"></span>

      <span index="2"></span>

      <span index="3"></span>

      <span index="4"></span>

      <span index="5"></span>

  </div>

  <a href="javascript:" id="prev" class="arrow">&lt</a>

  <a href="javascript:" id="next" class="arrow">&gt</a>

</div>

</body>

</html>

可以直接复制用,记得引入JQ库!

HTML中图片轮播代码如下:

<!DOCTYPE html>

<html>

<head><title>图片轮播代码</title>

<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0">

</head>

<style type="text/css">

    body{max-width: 640pxmargin: 0 auto}

    #lunbo ul li{width:100%list-style: nonewidth:640px height:250pxbackground-color: #f00text-align: center}

    #lunbo ul li:not(:first-child){display: none}</style><body><div id="lunbo">

    <ul>

        <li>1</li>

        <li>2</li>

        <li>3</li>

        <li>4</li>

    </ul></div><script type="text/javascript">

    //因为使用了document,所以js需要放在需要执行的代码下面生效才能生效

    var li=document.getElementById('lunbo').getElementsByTagName("li")

    var num=0

    var len=li.length

    setInterval(function(){

        li[num].style.display="none"

        num=++num==len?0:num

        li[num].style.display="inline-block"

    },3000)//切换时间

</script>

</body>

</html>

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=UTF-8" />

<title>五图三屏轮播js特效代码</title>

<meta name="Keywords" content="五图三屏轮播js特效代码" />

<meta name="description" content="五图三屏轮播js特效代码" />

<link href="http://img.chinaz.com/max-templates/passport/styles/topbar.css" type="text/css" rel="Stylesheet" />

<link href="/style/style_kj.css" type="text/css" rel="stylesheet" />

<link href="/style/demo.css" type="text/css" rel="stylesheet" />

<script type="text/javascript" src="/style/js/jquery-1.2.pack.js"></script>

<script type="text/javascript">

var theme_list_open = false

$(document).ready(function () {

function fixHeight() {

var headerHeight = $("#switcher").height()

$("#iframe").attr("height", $(window).height()-84 + "px")

}

$(window).resize(function () {

fixHeight()

}).resize()

//响应式预览

$('.icon-monitor').addClass('active')

$(".icon-mobile-3").click(function () {

$("#by").css("overflow-y", "auto")

$('#iframe-wrap').removeClass().addClass('mobile-width-3')

$('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active')

$(this).addClass('active')

return false

})

$(".icon-mobile-2").click(function () {

$("#by").css("overflow-y", "auto")

$('#iframe-wrap').removeClass().addClass('mobile-width-2')

$('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active')

$(this).addClass('active')

return false

})

$(".icon-mobile-1").click(function () {

$("#by").css("overflow-y", "auto")

$('#iframe-wrap').removeClass().addClass('mobile-width')

$('.icon-tablet,.icon-mobile,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active')

$(this).addClass('active')

return false

})

$(".icon-tablet").click(function () {

$("#by").css("overflow-y", "auto")

$('#iframe-wrap').removeClass().addClass('tablet-width')

$('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active')

$(this).addClass('active')

return false

})

$(".icon-monitor").click(function () {

$("#by").css("overflow-y", "hidden")

$('#iframe-wrap').removeClass().addClass('full-width')

$('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active')

$(this).addClass('active')

return false

})

})

</script>

<script type="text/javascript">

function Responsive($a) {

if ($a == true) $("#Device").css("opacity", "100")

if ($a == false) $("#Device").css("opacity", "0")

$('#iframe-wrap').removeClass().addClass('full-width')

$('.icon-tablet,.icon-mobile-1,.icon-monitor,.icon-mobile-2,.icon-mobile-3').removeClass('active')

$(this).addClass('active')

return false

}

</script>

</head>

<body id="by" style="overflow-y: hidden" >

<div id="switcher">

<div class="center">

<ul>

<li class="logoTop">在线预览!</li>

<div id="Device">

<li class="device-monitor"><a href="javascript:"><div class="icon-monitor"></div></a></li>

<li class="device-mobile"><a href="javascript:"><div class="icon-tablet"></div></a></li>

<li class="device-mobile"><a href="javascript:"><div class="icon-mobile-1"></div></a></li>

<li class="device-mobile-2"><a href="javascript:"><div class="icon-mobile-2"></div></a></li>

<li class="device-mobile-3"><a href="javascript:"><div class="icon-mobile-3"></div></a></li>

</div>

</ul>

<div class="muen_top">

<a href="/" class="indexactive">首页</a>

<a href="/tupian/" class="l11active" target="_blank">高清图片</a>

<a href="/moban/" class="l12active" target="_blank">模板</a>

<a href="/ppt/" class="l726active" target="_blank">ppt模板</a>

<a href="/tubiao/" class="l49active" target="_blank">图标</a>

<a href="/kuzhan/" class="l713active" target="_blank">酷站</a>

<a href="http://font.chinaz.com/" class="l13active" target="_blank">字体</a>

<a href="/psd/" class="l713active" target="_blank">PSD素材</a>

<a href="/shiliang/" class="l15active" target="_blank">矢量图</a>

<a href="/yinxiao/" class="l713active" target="_blank">音效</a>

<a href="/biaoqing/" class="l560active" target="_blank">表情</a>

<a href="http://desk.chinaz.com/" class="l713active" target="_blank">壁纸</a>

<a href="/donghua/" class="l653active" target="_blank">动画</a>

<a href="/jiaoben/" target="_blank">脚本</a>

<a href="/zhuanti/" target="_blank">专题</a>

</div>

<div class="tougao">

<a href="http://sc.chinaz.com/tougao.html" target="_blank">我要投稿</a>

</div>

</div>

</div>

<div id="iframe-wrap">

<iframe id="iframe" src="http://demo.sc.chinaz.com//Files/DownLoad/webjs1/201604/jiaoben4160/" frameborder="0" width="100%"></iframe>

</div>

<div id="footer-notice" class="kj_bottom">

<div style=" width:980pxmargin:0 auto">

<p class="left cut">

<span>名称:</span>

<a href="/jiaoben/160419378420.htm" title="点击下载" class="down" target="_blank">五图三屏轮播js特效代码</a>

<span>类型:</span>

<a href="/jiaoben/" title="脚本" target="_blank">脚本</a>

<span>标签:</span><a href="/tag_jiaoben/js.html" target="_blank">js</a><a href="/tag_jiaoben/JiuGongGe.html" target="_blank">九宫格</a><a href="/tag_jiaoben/TuPianQieHuan.html" target="_blank">图片切换</a><a href="/tag_jiaoben/TuPianLunBo.html" target="_blank">图片轮播</a>

</p>

<p class="left">

<span>分享到:</span>

<a title='分享到新浪微博' href="javascript:void(0)" id="fxwb" class="sn">新浪</a>

<a title='分享到腾讯微博' href='javascript:void(0)' onclick=posttoWb() class="tx">腾讯</a>

<a title="分享到QQ空间" href="javascript:window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(document.location.href))void(0)" class="qq">QQ空间</a>

</p>

<div class="clear"></div>

</div>

</div>

<script type="text/javascript">

var description = '五图三屏轮播js特效代码: 五图三屏轮播js特效代码是一款ZHIME织蜜内衣丝袜五图三屏图片切换特效。'

var sendT = {

getHeader: function () {

var g_title = description

var re = /<[^<>]*?font[^<>]*?>/gi

g_title = g_title.replace(re, "")

return g_title

},

getFirstImgSrc: function () {

var allPageTags = document.getElementsByTagName("div")

for (var i = 0i <allPageTags.lengthi++) {

if (allPageTags[i].className == 'downtext') {

if (allPageTags[i].getElementsByTagName("img")[0] &&allPageTags[i].getElementsByTagName("img")[0].width >200) {

return allPageTags[i].getElementsByTagName("img")[0].src

}

else {

return null

}

}

}

},

getContent: function () {

var allPageTagss = document.getElementsByTagName("div")

for (var i = 0i <allPageTagss.lengthi++) {

if (allPageTagss[i].className == 'downtext') {

return allPageTagss[i].innerHTML

}

}

}

}

document.getElementById("fxwb").onclick = function () {

(function (s, d, e, r, l, p, t, z, c) {

var f = 'http://service.weibo.com/share/share.php?appkey=872996044&', u = z || d.location, p = ['url=', e(u), '&title=', e(sendT.getHeader()), '&source=', e(r), '&sourceUrl=', e(l), '&content=', c || 'gb2312', '&pic=', e(p || '')].join('')

function a() {

if (!window.open([f, p].join(''), 'mb', ['toolbar=0,status=0,resizable=1,width=440,height=430,left=', (s.width - 440) / 2, ',top=', (s.height - 430) / 2].join(''))) u.href = [f, p].join('')

}

if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0)else a()

})(screen, document, encodeURIComponent, 'CHINAZ', 'http://sc.chinaz.com/', sendT.getFirstImgSrc(), null, null, null)

}

function posttoWb() {

var _tt = description

var _t = encodeURI(_tt.replace(/\s+$/, ''))

var _url = encodeURI(window.location)

var _appkey = encodeURI("258efff116d2466da9b7513cbae7de0b")

var _site = encodeURI('sc.chinaz.com')

var _pic = sendT.getFirstImgSrc()

var _u = 'http://v.t.qq.com/share/share.php?title=' + _t + '&url=' + _url + '&appkey=' + _appkey + '&site=' + _site + '&pic=' + _pic

window.open(_u, '转播到腾讯微博', 'width=700, height=580, top=320, left=180, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no')

}

</script>

<script type="text/javascript" src="/js/softinfo.js.aspx?id=534084" defer="defer" charset="UTF-8"></script>

<div style="display:none">

<script src="http://s4.cnzz.com/stat.php?id=300636&web_id=300636" language="JavaScript"></script>

</div>

</body>

</html>

自己修改一下就可以了