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

Fullpage.js底部高度自定义fp-auto-height样式无效的解决方案

2018-01-23 09:45 746 查看
近期用到Fullpage.js.底部不需要整屏,搜了很多.都说在底部区域加上fp-auto-height这个CSS样式即可.试了一下不行.

终极解决办法:

HTML部分:

<div class="section section5">
<!--这里是倒数第2屏-->
</div>
<!--最后一屏开始-->
<div class="section" id="section-footer">
<div id="footer-text">
<!--这里写底部版权信息等文字-->
</div>
</div>
<!--最后一屏结束-->CSS部分:
#section-footer{
background:#212020;
}
#section-footer #footer-text{
height: 150px!important;/*设置尾屏高度*/
}修改你的Jquery.Fullpage.js,找到function performMovement(v)这个方法:
if (options.css3 && options.autoScrolling && !options.scrollBar) {

//var translate3d = 'translate3d(0px, -' + v.dtop + 'px, 0px)';
if (v.anchorLink == 'footer')//判断当滚动到尾屏如何做
{
footer_a = $('#section-footer').height();
footer_h = $('#footer-text').height();
var translate3d = 'translate3d(0px, -' + (v.dtop - footer_a + footer_h) + 'px, 0px)';
}
else
{
var translate3d = 'translate3d(0px, -' + v.dtop + 'px, 0px)';
}
transformContainer(translate3d, true);

setTimeout(function () {
afterSectionLoads(v);
}, options.scrollingSpeed);
}

// using jQuery animate大概意思就是if一下当滚动到底部时再重新计算一下要滚动的高度.
最最最关键的一步:

因为判断的是anchors.所以要在fullpage的参数配置里面最后加上footer,否则会判断不到.



另外,如果没有VerticalCentered:false的话.在底部添加的文字可能会看不到.因为内容被垂直居中了.要进一步的处理.这里我很懒所以直接用VerticalCentered:这个参数.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: