具体效果是,浏览器滚动到一定距离的时候,fixed绝对定位的导航会显示,当滚动到小于这个距离的时候,导航会隐藏。
js部分:
<script>
function getTop() {
var mytop = $(document).scrollTop();
if (mytop > 400) {
$(".fixed_banner").css({
'display': 'block',
'top': 0,
});
} else {
$(".fixed_banner").css('display', 'none');
}
setTimeout(getTop);
}
getTop();
</script>
css部分
.fixed_banner {
position: fixed;
bottom: 10px;
height: 100px;
z-index: 10000;
display: none;
}