页面滚动从右向左

 <!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=utf-8" />
 <title>页面滚动</title>
 <style type="text/css">
 <!--
 *{padding:0; margin:0;}
 body{font:12px Arial, Helvetica, sans-serif; background:#fff;}
 img{border:0;}
 ul{list-style-type:none;}
 .switch{margin:20px auto; position:relative; width:929px; height:241px; border:solid 4px #FF0000; background:#ECEEED;}
 .switch_button{position:absolute; top:100px; right:4px; z-index:12; width:363px; height:17px; left:5px;}
 .switch_button dl{float:left; margin-right:6px; z-index:0;}
 .switch_button dl dt{overflow:hidden; display:none; float:left; padding-left:8px; height:30px; line-height:30px; width:0; font-size:30px; font-weight:bolder; }
 .switch_button dl dt a{color:#000; text-decoration:none;}
 .switch_button dl dt a:hover{color:#F00; text-decoration:underline;}
 .switch_button dl dt,.switch_button dl dd{float:left; margin-left:6px;}
 .switch_button dl dd{display:inline; overflow:hidden; height:13px; width:13px; line-height:14px; color:#f00; font-family:"宋体"; text-align:center; cursor:pointer;x}
 .switch_button dl dd.current{font-weight:700; color:#F8F4F1; }
 .l_button,.r_button{overflow:hidden; float:left; margin-top:3px; width:6px; height:11px; cursor:pointer;}
  /*.l_button{background:url( http://www.cnblogs.com/images/cnblogs_com/chenjmdg/20100112/switch_button_bg.gif) no-repeat left top;}
 .r_button{background:url( http://www.cnblogs.com/images/cnblogs_com/chenjmdg/20100112/switch_button_bg.gif) no-repeat left -11px;}
.swith_bg{position:absolute; z-index:11; height:26px; width:929px; top:200px; left:0; background:#000;}*/
 .switch_img{position:relative; overflow:hidden; width:929px; height:241px;}
 .switch_img ul li{position:absolute; overflow:hidden; z-index:0; left:929px; width:929px; height:241px; background:#fff;}
 -->
 </style>
 <script type="text/javascript" src=" http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
 <script type="text/javascript">
 <!--
 var DDSwitch = function(options){
  this.SetOptions(options);
  this.oSwithBg = this.options.oSwithBg;
  this.oSwithButton = this.options.oSwithButton;
  this.oSwithImg = this.options.oSwithImg;
  this.oSwithRbutton = this.options.oSwithRbutton;
  this.oSwithLbutton = this.options.oSwithLbutton;
  this.oSwithClear = this.options.oSwithClear;
 
  this.iSwithBg = $(this.oSwithBg);
  this.iSwithButton = $("#" + this.oSwithButton + " > dd");
  this.iSwithTitle = $("#" + this.oSwithButton + " > dt");
  this.iSwithImg = $(this.oSwithImg + " > ul > li");
  this.iSwithRbutton = $(this.oSwithRbutton);
  this.oSwithLbutton = $(this.oSwithLbutton);
  this.iSwithClear = $(this.options.oSwithClear)
  this.timer = null;
 
  this.init();
 
  this.ClickButton();
 
  var _this = this;
  this.iSwithClear.bind("mouseover", function(){
   _this.Stop();
  }).bind("mouseout", function(){
   _this.AutoButton("auto");
  });
 
  this.AutoButton("auto");
  this.ClickRLbutton();
 };
 DDSwitch.prototype = {
  SetOptions: function(options){
   this.options = {
    oSwithBg: ".swith_bg",
    oSwithButton: "switchButton",
    oSwithImg: ".switch_img",
    oSwithRbutton: ".r_button",
    oSwithLbutton: ".l_button",
    oSwithClear: ".switch_button"
   };
   $.extend(this.options, options || {});
  },
  init: function(){
   this.iSwithBg.css({ opacity: 0.3 });
   $(this.iSwithButton[0]).addClass("current");
   $(this.iSwithTitle[0]).css({ display: "block", width: "208px" });
   $(this.iSwithImg[0]).css({ "z-index": 1, left: 0 });
  },
  ClickButton: function(){
   var _this = this;
   for(var i = 0; i < this.iSwithButton.length; i++){
    (function(){
     var index = i;
     $(_this.iSwithButton[index]).click(function(){
      if($(_this.iSwithButton[index]).attr("class") == "current") return;
      for(var j = 0; j < i; j++){
       if(index == j){
        $(this).addClass("current");
        $(_this.iSwithTitle[index]).css({ display: 'block' });
        $(_this.iSwithTitle[index]).animate({ width: "+=208px" }, 500);
        $(_this.iSwithImg[index]).css({ "z-index": 3 });
        $(_this.iSwithImg[index]).animate({ left: "-=929px" }, {
         duration: 700,
         complete: function(){
          for(var k = 0; k < j; k++){
           k == index ? $(this).css({ "z-index": 1 }) : $(_this.iSwithImg[k]).css({ "z-index": 0, left: "929px" });
          }
         }
        });
       } else {
        $(_this.iSwithTitle[j]).stop(true, true);
        $(_this.iSwithImg[j]).stop(true, true);
        $(_this.iSwithTitle[j]).css({ display: "none", width: 0 });
        $(_this.iSwithButton[j]).removeClass();
       }
      }
     })
    })();
   }
  },
  Pointer: function(){
   for(var i = 0; i < this.iSwithButton.length; i++){
    if($(this.iSwithButton[i]).attr("class") == "current"){
     return i;
    }
   }
  },
  Action: function(state, direction){
   var _this = this, pointer = this.Pointer();
   switch(state.toLowerCase()){
    case "right":
     if(pointer >= (_this.iSwithButton.length - 1)) { pointer = -1 }
     break;
    case "left":
     if(pointer <= 0) { pointer = _this.iSwithButton.length }
     break;
   }
   var index = pointer + direction;
  
   for(var i = 0; i < _this.iSwithButton.length; i++){
    if( i == (index)){
     $(_this.iSwithButton[index]).addClass("current");
     $(_this.iSwithTitle[index]).css({ display: 'block' });
     $(_this.iSwithTitle[index]).animate({ width: "+=208px" }, 500);
     $(_this.iSwithImg[index]).css({ "z-index": 3 });
       $(_this.iSwithImg[index]).animate({ left: "-=929px" }, {
        duration: 700,
        complete: function(){
         for(var k = 0; k < i; k++){
          k == (index) ? $(this).css({ "z-index": 1 }) : $(_this.iSwithImg[k]).css({ "z-index": 0, left: "929px" });
         }
        }
       });
    } else {
     $(_this.iSwithTitle[i]).stop(true, true);
     $(_this.iSwithImg[i]).stop(true, true);
     $(_this.iSwithTitle[i]).css({ display: "none", width: 0 });
     $(_this.iSwithButton[i]).removeClass();
    }
   }
  },
  Stop: function(){
   clearTimeout(this.timer);
   },
  AutoButton: function(){
   var _this = this;
   if(arguments[0] == "auto"){
    this.timer = window.setTimeout(function(){ _this.AutoButton("auto"); _this.Action("right", 1); }, 3000);
   }
  },
  ClickRLbutton: function(){
   var _this = this;
   this.iSwithRbutton.click(function(){ _this.Action("right", 1); });
   this.oSwithLbutton.click(function(){ _this.Action("left", -1); });
  }
 };
 $(document).ready(function(){
  var zz = new DDSwitch();
 });
 //-->
 </script>
 </head>
 <body>
 <div id="debug"></div>
 <div class="switch">
  <div class="switch_img">
      <ul>
          <li><img src="images/buttom_0.jpg"/></li>
             <li><img src="images/buttom_1.jpg" /></li>
             <li><img src="images/buttom_2.jpg" /></li>
             <li><img src="images/buttom_3.jpg" /></li>
             <li><img src="images/buttom_2.jpg" /></li>
         </ul>
     </div>
    
    <div class="switch_button">
      <div class="l_button"></div>
         <dl id="switchButton">
          <dd></dd>
             <dt>1111</dt>
             <dd></dd>
             <dt>2222</dt>
             <dd></dd>
             <dt><a href="#">ccc</a></dt>
             <dd></dd>
             <dt><a href="#">ddd</a></dt>
             <dd></dd>
             <dt><a href="#">eee</a></dt>
         </dl>
         <div class="r_button"></div>
     </div>
  <div class="swith_bg"></div>
 </div>
 </body>
 </html>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值