footer定位頁面底部(代碼分享)
更新時間:2017年03月07日 17:24:25 作者:yonghuming
本文主要分享了footer定位頁面底部的實例代碼,具有很好的參考價值。下面跟著小編一起來看下吧
話不多說,請看代碼:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>footer定位</title> <style> *{ margin:0; padding: 0; } .box{ width: 100%; height:300px; background: pink; margin-bottom: 30px; } .footer{ background: red; width: 100%; height:30px; } </style> </head> <body> <div class="main"> <!--頭部開始--> <div class="box"> </div> </div> <!--底部--> <div class="footer"> </div> <script type="text/javascript" src='http://libs.baidu.com/jquery/2.0.0/jquery.js'></script> </body> </html> <script> $(document).ready(function () { var theWindow = $(window); function resized() { var windowSize=window.devicePixelRatio; if(windowSize==1){ var hg2 = $(window).height(); var main = $('.main').outerHeight(); var hg4 = $('.footer').outerHeight(); var hg=hg2-hg4 if( hg > main){ $('.footer').css({"position":'fixed','bottom':0,'left':0,"z-index":999,"width":"100%"}); }else{ $('.footer').css({"position":'static'}); } }else{ $('.footer').css({"position":'static'}); } } theWindow.resize(function () { resized(); }).trigger('resize'); }); </script>
以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!
您可能感興趣的文章:
- 懶加載實現(xiàn)的分頁&&網(wǎng)站footer自適應(yīng)
- 如何為RecyclerView添加Header和Footer
- Android ListView中動態(tài)顯示和隱藏Header&Footer的方法
- jQuery mobile的header和footer在點擊屏幕的時候消失的解決辦法
- 使用RecyclerView添加Header和Footer的方法
- 詳解Nginx服務(wù)器的nginx-http-footer-filter模塊配置
- Repeater的FooterTemplate顯示某列總計思路與代碼
- Repeater的FooterTemplate中控件內(nèi)容設(shè)置方法
相關(guān)文章
es6數(shù)組的flat(),flatMap()函數(shù)用法實例分析
這篇文章主要介紹了es6數(shù)組的flat(),flatMap()函數(shù)用法,結(jié)合實例形式分析了es6數(shù)組的flat(),flatMap()函數(shù)基本功能、使用方法及操作注意事項,需要的朋友可以參考下2020-04-04Javascript中的var_dump函數(shù)實現(xiàn)代碼
發(fā)現(xiàn)了一個非常好的JavaScript調(diào)試方法,目前看到的是可以打印Object/Array/Function/String四種類型,使用方法和PHP中的var_dump()一樣,只要直接dump(變量名)即可。2009-09-09有趣的script標簽用getAttribute方法來自腳本吧
有趣的script標簽用getAttribute方法來自腳本吧...2007-03-03