-
原生寫法
查看全部 -
js原生寫法
查看全部 -
封裝獲取id,和綁定時(shí)間+兼容
查看全部 -
JQ的方法
查看全部 -
避免瀏覽器bug
查看全部 -
封裝動(dòng)引用查看全部
-
前端查看全部
-
1、固定右側(cè)邊欄實(shí)現(xiàn)關(guān)鍵點(diǎn):
① CSS position fixed屬性
② 監(jiān)聽window上的滾動(dòng)事件
③ 右側(cè)邊欄設(shè)置fixed條件判斷:滾動(dòng)高度 + 屏幕高度 > 右側(cè)邊欄高度?
2、使用jQuery為我們部署在服務(wù)器上的地址: <script src="
3、① 多次用到的對(duì)象最好事先定義在一個(gè)變量里:var jWindow = $(window);//獲取window對(duì)象
?② jWindow.scroll(function(){ }//給window對(duì)象綁定滾動(dòng)事件
?③ var scrollHeight=jWindow.scrollTop();//窗口滾動(dòng)的高度?
④ var screenHeight=jWindow.height();//屏幕可視區(qū)域的高度
?⑤ var sideHeight=$('#side').height();//右側(cè)邊欄的高度?
4、部分關(guān)鍵代碼: if(scrollHeight+screenHeight>sideHeight){ $('#side').css({ 'top':-(sideHeight-screenHeight),//如果設(shè)成'top':0,就會(huì)跳到右側(cè)邊欄的最頂端 'right':0 }); }else{ $('#side').css({ 'position':'static';//position的默認(rèn)取值是static }); }?
部分關(guān)鍵代碼: window.onload=function (){ jWindow.trigger('scroll');//觸發(fā)window滾動(dòng)的事件 }; jWindow.resize(function (){ jWindow.trigger('scroll'); });
查看全部 -
1.封裝 取id 2.封裝瀏覽器兼容查看全部
舉報(bào)