Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

侧框缓冲运动特效(Buffer-movement.html文件) #3

Open
zlluGitHub opened this issue Apr 10, 2018 · 0 comments
Open

侧框缓冲运动特效(Buffer-movement.html文件) #3

zlluGitHub opened this issue Apr 10, 2018 · 0 comments

Comments

@zlluGitHub
Copy link
Owner

zlluGitHub commented Apr 10, 2018

  • offsetLeft与style.left的区别

      offsetLeft 获取的是相对于父对象的左边距, left 获取或设置相对于具有定位属性(position定义为relative)的父对象 的左边距。

      style.left 返回的是字符串,如28px,offsetLeft返回的是数值28,如果需要对取得的值进行计算,还用offsetLeft比较好。

  • math取值举例:

    Math.ceil</a>(2.4));  //3 
    Math.floor</a>(2.4));  //2
    Math.round(2.5));   //3
  • setInterval与setTimeout()定时器的区别:

    setInterval()是一种定时器,它按照指定的设置时间(以毫秒计)来调用函数的方法。clearInterval()是结束定时器的循环调用函数。

    setTimeout()同理也是一种定时器,对应的结束定时的方法是clearTimeout()。与setInterval()不同的是,此定时器只执行一次。

    举例:
    
     var i = 0; //定义一个变量i
          var t = setInterval(function(){
            if(i === 60){
                clearInterval(t);  //假如i是60,则清除此定时器,结束循环回调
            }else{
                  i++;
                  console.log(i);
                 }
          },1000);
          
          var t = setTimeout(function(){
              console.log("OK");    //一秒后在控制台输出字符串"OK"
     },1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant