根据里面的内容自动调整div的高度

时间:2021-01-11 11:24:53

标签: html css

我想在不设置主 div 固定高度的情况下自动调整 div 内容的高度,但我不确定如何。我试过 height:100%height: auto

这是我的代码:

 .tmr_box {
     height: 470px;
}
 .tmr_inner {
     position: fixed;
     width: 100%;
     max-height: 440px;
     overflow-x: hidden;
     white-space: nowrap;
     height: auto;
     overflow-y: auto;
     max-width: calc(40% + 110px);
}
<form>
    <div class="row" style="margin-top: 10px;">
        <div class="col-md-6 tmr_box" ng-if="vm.tmr">
            .....
        </div>
        <div class="col-md-6 tmr_box" ng-if="vm.tmr">
            <table>
                ...
            </table>
        </div>
    </div>
</form>

没有固定高度属性,它看起来像这样。 enter image description here 预先感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我认为问题来自 div 内容的 position:fixed (.tmr_inner)。正因为如此,父 div 渲染时没有过多关注他。您应该尝试删除此属性或将其添加到父级 (tmr_box)。