【问题标题】:100% fluid width 100% height layout in Bootstrap jQuery works fine in FireFox but is totally messed up in ChromeBootstrap jQuery 中的 100% 流体宽度 100% 高度布局在 FireFox 中运行良好,但在 Chrome 中完全搞砸了
【发布时间】:2014-08-04 16:11:54
【问题描述】:

感谢 Kristian 的帮助,现在可以正常工作

https://jsbin.com/qivevo/1/edit?html,css

最终的解决方案是不同的jQuery。


原问题:

这是我通过将各种东西拼凑而成的布局,它在 FireFox 中运行良好,但在 Chrome 中,outerHeight 计算不正确或速度很慢。我不知道这是否可以修复。

在高显示器上的 FireFox 中查看:jsbin.com/yuyey/1,如果所有内容都适合高度,则没有水平滚动条,因为您将窗口缩小到主列中的内容,页脚碰到它并且不重叠,您可以滚动到它,这是所需的行为。在 Chrome 上查看同一个监视器,虽然现在使用我添加的脚本效果更好,但它计算不正确并且覆盖了内容。

演示:jsbin.com/yuyey/1

FireFox 按预期工作:

代码:

/* uses a script to get height, but with or without this script it doesn't work in chrome as it should */
    var navbarht = $('.navbar').actual('outerHeight');
    var footerht = $('.footer').actual('outerHeight');



 function columnHeight() {
     // Column heights should equal the document height minus the header height and footer height
     var newHeight = $(document).height() - (navbarht) - (footerht) + "px";
     $(".primary-col").css("height", newHeight);
     $(".secondary-col").css("height", newHeight);
     $(".tertiary-col").css("height", newHeight);

 }


 $(window).on('load resize', function() {
 $(".primary-col").css("height", "");
     $(".secondary-col").css("height", "");
     $(".tertiary-col").css("height", "");
     columnHeight();
 });


 //$('.site-main').css('padding-top', $('.navbar-fixed-top').outerHeight() + 'px');

 var bumpIt = function() {
         $('.footer').css('margin-top', -(footerht) + 'px');
         $('.sticky-footer-wrap').css('padding-bottom', (footerht) + 'px');
     },
     didResize = false;

 bumpIt();

 $(window).resize(function() {
     didResize = true;
 });
 setInterval(function() {
     if (didResize) {
         didResize = false;
         bumpIt();
     }
 }, 250);

【问题讨论】:

    标签: jquery google-chrome twitter-bootstrap-3 webkit


    【解决方案1】:

    好的,问题是负边距让页脚与内容重叠,因为它可以向上移动。我们需要通过添加一些填充在主要内容的底部添加相同数量的空间来解决此问题:

    http://jsbin.com/rakadizo/1

     var bumpIt = function() {
       $('.site-main').css('padding-bottom', (footerht) + 'px');
       $('.footer').css('margin-top', -(footerht) + 'px');
     },
     didResize = false;
    

    【讨论】:

    • 你是对的,计算错误,因为它是一个静态导航栏,但即使计算正确:jsbin.com/vatih/2,它仍然无法正常工作。页脚是静态的或相对的,因此当视口较短时它不会覆盖内容。在 Firefox 中它可以正常工作。
    • 我不确定我是否理解问题所在。它似乎在这里工作正常。你试过我的链接吗?也许你可以试着澄清一下?
    • 查看这个:jsbin.com/yuyey/1 在高显示器上的 FireFox 中,如果所有内容都符合高度,则没有水平滚动条,因为您将窗口缩小到主列中的内容,页脚碰到它并且不重叠,您可以滚动到它,这是所需的行为。在 Chrome 上查看同一个监视器,虽然现在使用我添加的脚本效果更好,但它计算不正确并且覆盖了内容。
    • @BootstrapThemer 我已经更新了我的答案,现在它在 chrome 中的工作方式相同。
    • 你摇滚!我很感激。我将在 IOS 和其他浏览器中对此进行测试,希望如此。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-17
    • 2019-03-08
    • 2013-02-16
    • 1970-01-01
    • 2014-12-25
    • 2014-12-07
    相关资源
    最近更新 更多