0514-86177077
9:00-17:00(工作日)
本文介紹了詳解HTML5將footer置于頁面最底部的方法(CSS+JS),分享給大家,具體如下:
JavaScript:
<script type="text/javascript"> $(function(){ function footerPosition(){ $("footer").removeClass("fixed-bottom"); //網頁正文全文高度 var contentHeight = document.body.scrollHeight, //可視窗口高度,不包括瀏覽器頂部工具欄 winHeight = window.innerHeight; if(!(contentHeight > winHeight)){ //當網頁正文高度小于可視窗口高度時,為footer添加類fixed-bottom $("footer").addClass("fixed-bottom"); } else { $("footer").removeClass("fixed-bottom"); } } footerPosition(); $(window).resize(footerPosition); }); </script>
CSS:
.fixed-bottom { position: fixed; bottom: 0; width:100%; }
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
標簽:淮安 咸寧 廣西 南京 酒泉 十堰 佳木斯 西寧
上一篇:HTML5實現簽到 功能
下一篇:iframe在移動端的縮放的示例代碼
Copyright ? 1999-2012 誠信 合法 規范的巨人網絡通訊始建于2005年
蘇ICP備15040257號-8