【发布时间】:2016-01-19 07:17:28
【问题描述】:
我想要一个图像在我的引导网格布局中完全填充一个 div。但是,当我尝试以下操作时,它仍然会在图像的侧面和底部留下可见的边距。这是我的代码:
<div class="container"
<div class="row equalheight">
<div class="col-md-8 index-featured-image div-fill">
<!--featured image -->
<img src="http://placehold.it/400x200">
</div>
<div class="col-md-4 index-featured-about">
<h2>this is about the featured post.</h2>
<p>This is the content</p>
</div>
</div>
</div>
还有 CSS:
.container {
width: 100%;
height: auto;
}
.col-md-4 {
height: 100%;
background-color: green;
border-top:solid white 20px;
border-bottom:solid white 20px;
overflow: hidden;
}
.col-md-8 {
height: 100%;
background-color: black;
border-right: solid white 20px;
border-top:solid white 20px;
border-bottom:solid white 20px;
}
.col-md-8 img {
width: 100%;
height: 100%;
}
感谢您的帮助!几个小时以来,我一直在努力解决这个问题!
【问题讨论】:
-
首先关闭这个 div
<div class="container"> -
您是否在任何浏览器的开发人员工具(Firefox 或 Chrome 中的 Ctrl-Shift-I)中检查过这个?这将立即告诉您出了什么问题,并且始终是解决 CSS 布局问题的起点。
标签: html css image twitter-bootstrap