您好,欢迎来到源码搜藏!分享精神,快乐你我!提示:担心找不到本站?在百度搜索“源码搜藏”,网址永远不丢失!
  • 首 页
  • 在线工具
  • 当前位置:首页 > 网页特效 > 图片特效 >

    适合游戏网站的jQuery自适应图片大小的焦点图代码

    时间:2013-12-19 09:02 来源:互联网 作者:源码搜藏 浏览:收藏 挑错 推荐 打印

    运行代码保存代码复制代码 提示:您可以先修改部分代码再运行,保存代码功能在Firefox下无效。
    • jQuery自适应图片大小的游戏类网站焦点图代码,兼容主流浏览器。调试方法:1、引入jquery.js文件;2、复制css代码到你的CSS文件中;3、拷贝"焦点图代码"注释区的内容到你的页面中就行了。代码中的CSS html选择器内去掉了滚动条,因为图片太高时出现了右侧滚动条 滚动条会让ul宽度变化的效果看起来有点震动,从而影响整体的幻灯片效果。
    • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
      <title>jq焦点图自适应图片大小而变化[www.codesocang.com]</title>
      <script type="text/javascript" src="http://www.codefans.net/ajaxjs/jquery-1.6.2.min.js"></script>
      <script type="text/javascript">
      $(function (){
      var x=0,width,height,ul=$(".content"),bottom=$(".bottom"),t
      function img_block(){
      bottom.stop();
      ul.stop();
      $(".content li").css("display","none");
      bottom.css({"height":"0px"});
      $("#xz").text(x+1);
             width=parseInt($(".content li:eq("+x+")").css("width"));
      height=parseInt($(".content li:eq("+x+")").css("height"));
      ul.animate({"width":width+"px","height":height+"px"},500,function (){
      $(".content li:eq("+x+")").css("display","block");
      bottom.css("width",width+"px");
      bottom.animate({"height":"50px"});
      $(".left,.right").css({"width":width/2+"px","height":height+"px"})
      });
      };
      function rights(){
      if(x==$(".content li").length-1){x=0;}
      else{x++};
      img_block();
      };
      $(document).ready(function() {
      $("#imgdata").text($(".content li").length);
      img_block();
      t=setInterval(rights,4000);
         });
      $(".right").click(function (){rights()});
      $(".left").click(function (){
      if(x==0){x=$(".content li").length-1;}
      else{x--};
      img_block();
      });
      $(".right,.right").hover(function (){clearTimeout(t)},function (){t=setInterval(rights,4000)});
      });
      </script>
      <style>
      html{overflow:-moz-scrollbars-vertical ; overflow:scroll; overflow-x:hidden; overflow-y:hidden;}
      *{padding:0 ; margin:0 ;}
      ul{list-style:none;}
      body{background:#CCCCCC;}
      .container{width:100%; height:100%; margin-top:3%;}
      .content{background:#ffffff; margin:0 auto; position:relative; width:220px; height:100px; border: 15px solid #ffffff;}
      .content li{position:absolute; top:0; left:0; display:none;}
      .content span{position:absolute; left:47%; top:45%;}
      .content .left,.content .right{position:absolute; top:0; z-index:11;}
      .content .left{cursor:url(http://www.codefans.net/jscss/demoimg/201312/cur-left.cur.ico), auto; left:0;}
      .content .right{right:0; cursor:url(http://www.codefans.net/jscss/demoimg/201312/cur-right.cur.ico), auto;}
      .bottom{height:0px; background:#ffffff; margin:0 auto; overflow:hidden; line-height:50px; padding: 0 15px;}
      </style>
      </head>
      <body>
      <div class="container">
      <!--焦点图代码开始 -->
      <ul class="content">
          <span><img src="images/5-121204193956-50.gif" width="32" height="32" /></span>
              <div class="left"></div>
              <div class="right"></div>
              <li style="background:url(/jscss/demoimg/201312/img_1.jpg); width:856px; height:482px;"></li>
              <li style="background:url(http://www.codefans.net/jscss/demoimg/201312/img_2.jpg); width:904px; height:723px;"></li>
              <li style="background:url(http://www.codefans.net/jscss/demoimg/201312/img_3.jpg); width:816px; height:459px;"></li>
              <li style="background:url(http://www.codefans.net/jscss/demoimg/201312/img_4.jpg); width:860px; height:484px;"></li>
              <li style="background:url(http://www.codefans.net/jscss/demoimg/201312/img_5.jpg); width:960px; height:540px;"></li>
              <li style="background:url(http://www.codefans.net/jscss/demoimg/201312/img_6.jpg); width:910px; height:683px;"></li>
              <li style="background:url(http://www.codefans.net/jscss/demoimg/201312/img_7.jpg); width:960px; height:540px;"></li>
          </ul>
          <div class="bottom">共 <span id="imgdata">x</span> 张 / 第 <span id="xz">x</span> 张</div><br /><br />
      <!-- 焦点图代码结束 -->
      <p>jQuery自适应图片大小焦点图代码,兼容主流浏览器</p><p><br /></p><p>调试方法:</p><p>1、引入jquery.js文件</p><p>2、复制以上css样式代码到你的CSS文件中。</p><p>3、拷贝<焦点力代码>注释区的内容到你的页面中。</p>
      <p style="margin:20px 0"></p>
      </div>
      </body>
      </html>

    适合游戏网站的jQuery自适应图片大小的焦点图代码由源码搜藏网整理,转载请注明出处http://www.codesocang.com/texiao/pic/6519.html
    标签:网站源码