Javascript 当粘贴div大于内容和窗口时,粘贴引导出现问题
当affix div大于主内容和窗口时,我对affix引导有一个问题 在这里,一切正常,因为有足够的内容: 当内容不够大时,请参见此处的问题:(当“粘贴顶部”变为“粘贴”时存在问题) 当没有足够的内容时,如何修复它以使affix div保持静态而不固定Javascript 当粘贴div大于内容和窗口时,粘贴引导出现问题,javascript,css,twitter-bootstrap-3,fixed,affix,Javascript,Css,Twitter Bootstrap 3,Fixed,Affix,当affix div大于主内容和窗口时,我对affix引导有一个问题 在这里,一切正常,因为有足够的内容: 当内容不够大时,请参见此处的问题:(当“粘贴顶部”变为“粘贴”时存在问题) 当没有足够的内容时,如何修复它以使affix div保持静态而不固定 谢谢从中删除绝对位置。粘贴底部 .affix-bottom{ position:absolute /* Comment out this line */ } 使用jquery,获取文档的高度,减去页眉和页脚高度。然后用这个在词缀上加一个if语句
谢谢从
中删除绝对位置。粘贴底部
.affix-bottom{
position:absolute /* Comment out this line */
}
使用jquery,获取文档的高度,减去页眉和页脚高度。然后用这个在词缀上加一个if语句
if(contentHeight > sidebarHeight) {
$('#account-overview-container').affix({
offset: {
top: headerHeight,
bottom: footerHeight
}
}).on('affix.bs.affix', function () { // before affix
$(this).css({
/*'top': headerHeight,*/ // for fixed height
});
})
}
演示:
if(contentHeight > sidebarHeight) {
$('#account-overview-container').affix({
offset: {
top: headerHeight,
bottom: footerHeight
}
}).on('affix.bs.affix', function () { // before affix
$(this).css({
/*'top': headerHeight,*/ // for fixed height
});
})
}