我在bootstrap中遇到了一些容器问题.我的目标是拥有一个只有内容高的容器.例如:
<div class="container">
<img src="#.jpg" height="200px" width="300px">
</div>
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,容器应该只与图像一样高.但是,即使我通过CSS将容器的最小高度设置为0px,我的浏览器也会自动在元素样式中集成最小高度594px.浏览器中的源代码如下所示:
<div class="container" style="min-height: 594px;">
<img src="#.jpg" height="200px" width="300px">
</div>
Run Code Online (Sandbox Code Playgroud)
但是在HTML文件中没有定义样式元素.Chrome和IE都会出现这种情况.因此,CSS代码(min-height:0px;)被忽略.
CSS:
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
max-width: 900px;
overflow:hidden;
min-height:0px;
}
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?