下拉后首层跟滚动条移动

window.onscroll = function()

{

  var c = document.getElementById("caidan");

   var l = document.getElementById("l");

  var lh = l.style.height;

  if(window.scrollY >= parseInt(lh))

  {

     c.style.position = "fixed";

     c.style.top = "0px";

   }

  else

   {

     c.style.position = "relative";

   }

}

 

 

posted @ 2018-04-15 08:43  k丶灵  阅读(82)  评论(0)    收藏  举报