您的位置:首页 > Web前端 > BootStrap

bootstrap 固定底部导航自适应

2016-09-07 18:00 393 查看
在使用bootstrap 底部导航的时候遇到了一个问题 —— 当我的内容超过一屏的时候,底部的部分内容会被固定的导航内容遮盖

 

自己写了一个JS脚本,解决自适应的问题

<nav class="navbar navbar-default navbar-fixed-bottom">
<div class="container-fluid margin_bottom_5 margin_top_5 clear_padding text-center">
<button class="btn btn-e4005a" type="button" style="padding: 6px 30px;">提交</button>
</div>
</nav>

<script>

$(function(){
autoNav();
});

//解决底部自动导航的问题
function autoNav(){
//获取内容的高度
var bodyHeight = $("body").height();
//获取底部导航的高度
var navHeight = $(".navbar").height();
//获取显示屏的高度
var iHeight = document.documentElement.clientHeight||document.body.clientHeight;
//如果内容的高度大于(窗口的高度 - 导航的高度),z则需要添加一个div,设置其高度
if(bodyHeight > (iHeight - navHeight)){
$("body").append('<div style="height: '+navHeight+'px"></div>');
}
}

</script>

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: