开发者

How to have elements copy other element's auto height css?

开发者 https://www.devze.com 2023-03-30 03:35 出处:网络
I have a right column on my page that has varying heights, set as height: auto; I also have a left content section, that I want to mimic the height of my 开发者_如何学运维right column.

I have a right column on my page that has varying heights, set as height: 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?


$(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.

http://jsfiddle.net/pUXCE/4/ <-- working example.

0

精彩评论

暂无评论...
验证码 换一张
取 消