zoukankan      html  css  js  c++  java
  • js随笔

    nav横幅滚动

    html代码

    1 <div class='box'>
    2     <label class='tips'><span id='tip'>我是我是我是我是顶上的横幅</span></label>
    3 </div>

    js代码

     1  function scrollTip(){
     2     var flag = 0;
     3     setInterval(function () {
     4       var tip = $('#tip');
     5       var box = $('.box').eq(0);
     6       var marginLeft = (tip.css('marginLeft')).replace('px','');
     7       if((Math.abs(marginLeft)+(box.width()))==(tip.width()+30)){
     8         flag = 1;
     9       } else if(Math.abs(marginLeft) == 0) {
    10         flag = 0;
    11       }
    12       if(flag === 0){
    13         tip.css('marginLeft',(marginLeft-1)+'px');
    14       } else {
    15         tip.css('marginLeft',(parseInt(marginLeft)+1)+'px');
    16       }
    17     },50);
    18   }
    19   scrollTip();
  • 相关阅读:
    CentOS 6.x 系统安装选项说明
    MySQL表的操作
    6月13号
    6月11号
    6月10号
    6月9号
    6月6
    day27
    day 28
    day 29
  • 原文地址:https://www.cnblogs.com/margarita/p/5485485.html
Copyright © 2011-2022 走看看