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:这个参数.
终极解决办法:
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:这个参数.
相关文章推荐
- jQuery全屏滚动插件fullPage.js使用中遇到的问题(滑动轮播效果无效)
- 使用jquery.fullpage.js需要动态改变导航小圆点的样式
- css clearfix(针对火狐height:auto无效解决方案)
- css clearfix(针对火狐height:auto无效解决方案)
- Fullpage.js 单屏高度超过屏幕高度,实现滚动条滑动的方法
- js获取height为auto的高度问题
- 关于js设置标签样式来显示图片背景无效的解决方案
- css clearfix(针对火狐height:auto无效解决方案)
- Fullpage.js导航颜色无法更改解决方法(navigationColor无效)
- fullpage.js全屏滚动插件使用小结
- js实现文件上传自定义样式
- jquery的height()和javascript的height总结,js获取屏幕高度
- fullpage.js全屏滚动插件使用实例
- js 里不能使用${pageContext.request.contextPath}解决方案
- JS获取网页高度及屏幕分辨率高度让DIV层始终在页面最底部
- HTML/CSS/JavaScript fullPage.js的使用
- 自定义上传按钮样式的终极解决方案_input透明法
- IE8中height100%无效解决方案
- js获取滚动条距离浏览器顶部,底部的高度,兼容ie和firefox