【发布时间】:2015-10-25 15:30:02
【问题描述】:
我使用以下函数分析两列(内容和侧边栏)并确保 div 的高度相等。此功能仅在列需要增加大小时起作用。因此,当内容大小减小时,会导致列过大。
如何更改此代码以解决内容尺寸减小的问题(例如,如果窗口大小从中等宽度变为大宽度,并且最高的内容高度会降低。)
var sidebarSameHeight = function() {
//Sidebar Same Height - http://html-tuts.com/make-sidebar-same-height-as-content-div/
// placing objects inside variables
var content = $('.core_content_main');
var sidebar = $('.core_content_sidebar');
// get content and sidebar height in variables
var getContentHeight = content.outerHeight();
var getSidebarHeight = sidebar.outerHeight();
// check if content height is bigger than sidebar
if ( getContentHeight > getSidebarHeight ) {
sidebar.css('min-height', getContentHeight);
}
// check if sidebar height is bigger than content
if ( getSidebarHeight > getContentHeight ) {
content.css('min-height', getSidebarHeight);
}
};
sidebarSameHeight();
setInterval(sidebarSameHeight, 250);
【问题讨论】:
标签: jquery css height multiple-columns