我使用 jquery 和 css 创建了一个 2 列布局。一栏是 div 主要内容,另一栏是侧边栏。
jquery代码是
var divone = jQuery(".main-content").height();
var divtwo = jQuery(".sidebar").height();
var mainheight = $(window).height() - $('header').height() - $('footer').height();
jQuery(".main-content").height(mainheight);
jQuery(".sidebar").height(mainheight);
演示在 demo.
我的问题是它只适用于 firefox 和 chrome。它在 IE 10 中乱七八糟。
我希望它适用于所有主流浏览器。感谢您的帮助。
更新:
最佳答案
我对 jsfiddle 进行了编辑
var t_height =$('html').height();
var h_height =$('.header').height();
var f_height =$('footer').height();
alert(t_height)
alert(h_height)
alert(f_height)
var div_h = t_height-h_height-f_height;
var divone = jQuery(".main-content").css('height',div_h);
var divtwo = jQuery(".sidebar").css('height',div_h);
但是我突然意识到你的例子在 IE10 中也适用于我
对 html
做了一些修改,但它们不是必需的
关于jquery - 制作具有相同高度的两列布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17169344/