我的Flex框的孩子有孩子自己,对这些孩子中的一个(<img>
我用object-fit:cover
,以确保所有的图像块将是相同的高度/宽度)。Flexbox的孩子的孩子四溢
问题是第二个孩子(<h4>
标签)没有被包含在Flex Box中并且看起来溢出。
到目前为止,我的努力导致<h4>
标签装配,但object-fit: cover
停止工作。
这可能吗?
#content {
margin-left: 18%;
margin-right: 18%;
/*border: 1px solid black;*/
}
h1.page-title {
margin-top: 0;
padding: 39px 0px 39px 150px;
}
.image-pane {
display: flex;
background-color: rgba(0, 0, 0, 0.2);
}
.image-tile {
margin: 1%;
width: 48%;
}
span.image-tile>img{
width: 100%;
height: 100%;
object-fit: cover;
box-shadow: 5px 5px 20px 1px rgba(0, 0, 0, 0.2);
}
.image-text {
font-family: aftaSansRegular;
text-align: center;
}
<div id="content">
<h1 class="page-title">
Galleries
</h1>
<div class="image-pane">
<span class="image-tile">
<img src="http://i.turner.ncaa.com/ncaa/big/2016/03/21/379123/1458530071096-mbk-312-wisconsin-xavier-1920.jpg-379123.960x540.jpg" alt="Basketball Image 01"/>
<h4 class="image-text">
Sports
</h4>
</span>
<span class="image-tile">
<img src="https://www.bahn.com/en/view/mdb/pv/agenturservice/2011/mdb_22990_ice_3_schnellfahrstrecke_nuernberg_-_ingolstadt_1000x500_cp_0x144_1000x644.jpg" alt="Train Image 01"/>
<h4 class="image-text">
Models
</h4>
</span>
</div>
</div>
在答复你可以请提供它为什么会发生这样的解释,所以我能理解它而并非只是纠正:'P
将块元素放入内联块中 – Morpheus
它是如何溢出的? ...对我来说,Chrome/Firefox看起来不错 – LGSon
这两个标签都放置在环绕图像的灰色框外。我在Chrome 60.0.3112.113 –