Html 自动设置高度,而不是在引导模式下显示滚动条

Html 自动设置高度,而不是在引导模式下显示滚动条,html,css,twitter-bootstrap,twitter-bootstrap-3,bootstrap-modal,Html,Css,Twitter Bootstrap,Twitter Bootstrap 3,Bootstrap Modal,Bootstrap模式上有两个输入,它们通过dropdownlist值显示/隐藏。我隐藏了模式的滚动条,并希望随着dropdownlist所选索引的更改,模式自动增加/减少其高度。虽然我尝试在模式的每个div中使用“height:auto!important;”“,但它不能自动更改(但在我将高度设置为像素值时会更改)。那么,有没有可能自动做到这一点 <style> .modal { overflow-y: hidden !important;

Bootstrap模式上有两个输入,它们通过
dropdownlist
值显示/隐藏。我隐藏了模式的滚动条,并希望随着dropdownlist所选索引的更改,模式自动增加/减少其高度。虽然我尝试在模式的每个
div
中使用“height:auto!important;”“,但它不能自动更改(但在我将高度设置为像素值时会更改)。那么,有没有可能自动做到这一点

<style>
    .modal {        
        overflow-y: hidden !important;
        max-height: 100%;
    }
</style>



<!-- /.modal -->
<div id='accountModal' class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-body">
        <div id='accountModalContainer' class="modal-dialog" 
            style="width:600px !important; max-height:1000px; height:auto !important;">
        </div>
    </div>
</div>                    
<!-- /.modal -->

.modal{
溢出y:隐藏!重要;
最大高度:100%;
}

以下是针对遇到相同问题的人的解决方案:

<style>
.modal {
    position: absolute;
    display: table; /* This is the most important feature */
    overflow-y: hidden !important;
    width:100%; 
}
</style>

.莫代尔{
位置:绝对位置;
显示:table;/*这是最重要的功能*/
溢出y:隐藏!重要;
宽度:100%;
}
有关更多信息,请查看第页阿米特·沙阿的答案。

请查看此答案

我用额外的css对.modal主体类做了一些调整

.modal-dialog {
    width: auto;
}
.modal-body {
    max-height: calc(100vh - 225px);
    overflow: auto;
}

您能告诉我们您做了什么吗far@Abhijeet我在问题中添加了我的代码。如果您添加与模态相关的全部代码,并详细说明您想要的最终输出,这将非常有用。因为我使用了几个partialview,这对我来说有点困难,但在模态类中使用display:table时,问题可以解决。但是,在这种情况下,即使我使用position:absolute属性,也无法在屏幕中心打开模式并在左侧打开模式。有没有办法在屏幕中央打开它?