【发布时间】:2016-09-19 20:17:46
【问题描述】:
我需要修复订单摘要侧边栏,就像所附图片中的那样,侧边栏应该如图所示停止,但有时它会低于页脚。
我正在使用 Bootstrap 3.0.0 附加插件来修复我的 opencart 商店结帐页面侧边栏中的订单摘要。
<script type="text/javascript">
$(document).ready(function(){
var headerHeight = $('header').outerHeight(true);
var c = $('.custom-footer').outerHeight();
var f = $('.full-width').outerHeight();
var footerHeight =c + f+ 60;
$('#summary-div').affix({
offset: {
top: 270,
bottom: footerHeight // using bottom value like this never always makes the order summary div to overlap the footer
//bottom :455 // I get affixed sidebar when i use bottom value as 455 but it sometimes overlaps the footer
}
}).on('affix.bs.affix', function() { // before affix
$(this).css({
'width': $(this).outerWidth() // variable widths
});
});
});
</script>
<style type="text/css">
#summary-div.affix{
position: fixed;
top: 0px;
width: 28.8%;
}
.affix-top{
position: static;
}
.affix-bottom{
position:absolute;
bottom:auto !important;
}
</style>
我已经更新了问题和图片。
【问题讨论】:
-
尝试将 $('.custom-footer').outerHeight(true) 设置为词缀外的变量。我想知道 JS 是否跟不上试图快速返回该高度参数的浏览器。
-
@crazymatt 你现在可以看看我添加了一张图片并更改了我的问题的详细信息以更详细地说明它,请帮助
-
不可能用所提供的小代码来判断问题所在。无论如何,您可以在js.fiddle 中重现该问题或提供更多代码?您是否也尝试过在 HTML 中添加代码而不是通过 JS,只是为了看看问题是否仍然存在?
-
@crazymatt 我无法在 js.fiddle mdpocket.com 中实现该问题,这是商店的网站。我请求您先生,请为我努力并去网站注册一个帐户并在购物车中添加一些物品并转到结帐页面。请建议我如何使订单摘要侧边栏浮动。 P.S:在实时网站上,我没有为浮动侧边栏实现任何代码。我只是想让你去网站看看你能不能弄清楚一些事情。先生,这将是一个很大的帮助
-
连一行源代码都没有!!!你期望如何给出答案!!!
标签: jquery html css twitter-bootstrap affix