我有一个绝对定位的 div 在相对定位的 div 内部。
我需要父级相对定位的 div 调整大小以适应绝对定位 div 的大小(这是动态更改的,取决于它在哪个页面上)
我已经阅读了可以使用 jQuery 完成此操作,但我无法使其正常工作。
以下是我的代码...
Html
<div class="product-view">
<div style="float:left;">Product Image</div>
<div class="product-shop">
<div id="mm_grid_wrapper">
<table>dynamic content</table>
</div>
CSS...
.product-view {
margin-top: 5px;
border: 1px solid #cecece;
padding: 22px 0 0 0;
position: relative;
bottom:0px;
}
.product-view .product-shop {
text-align: left;
width: 48%;
float: left;/*max-width: 329px;*/
}
#mm_grid_wrapper{
position:absolute;
left:10px;
margin:0 310px 0 0;
max-width: 1630px;
top:0;
height:100%;
}
}
javascript...
$(function()
{
$('.product-view') .css({'height': (($('#mm_grid_wrapper').height()) + 20)+'px'});
$('#mm_grid_wrapper').bind('resize', function(){
$('.product-view') .css({'height': (($('#mm_grid_wrapper').height()) +20)+'px'});
});
});