I have a right column on my page that has varying heights, set as height: auto;
我的页面上有一个不同高度的右列,设置为高度:auto;
I also have a left content section, that I want to mimic the height of my right column.
我还有一个左边的内容部分,我想要模拟右边列的高度。
How can I do this using css, jquery, or some other code?
如何使用css、jquery或其他代码实现这一点?
1 个解决方案
#1
6
$(document).ready(function() {
var x = $('#primary').height();
$('#sidebar').css('height', x);
});
This jQuery snippet will take the height of #primary
and apply it to #sidebar
, syncing the height of both elements.
这个jQuery代码片段将使用#primary的高度并将其应用到#侧栏,同步两个元素的高度。
http://jsfiddle.net/pUXCE/4/ <-- working example.
http://jsfiddle.net/pUXCE/4/ <——工作的例子。
#1
6
$(document).ready(function() {
var x = $('#primary').height();
$('#sidebar').css('height', x);
});
This jQuery snippet will take the height of #primary
and apply it to #sidebar
, syncing the height of both elements.
这个jQuery代码片段将使用#primary的高度并将其应用到#侧栏,同步两个元素的高度。
http://jsfiddle.net/pUXCE/4/ <-- working example.
http://jsfiddle.net/pUXCE/4/ <——工作的例子。