我有一个 div 是vh
屏幕的 1/5。我希望该 div 中的图像垂直居中。我能够将它水平居中,但到目前为止已经尝试了以下代码:
http://jsfiddle.net/ws91188y/1/
img{
width:25px;
}
.container-fluid > div{
text-align:center;
height: calc(100vh/5);
}
.container-fluid > div:nth-child(odd){
background:yellow;
}
<div class="container-fluid">
<div><img src="http://lorempixel.com/output/food-h-g-164-166-5.jpg"></div>
<div><img src="http://lorempixel.com/output/food-h-g-164-166-5.jpg"></div>
<div><img src="http://lorempixel.com/output/food-h-g-164-166-5.jpg"></div>
<div><img src="http://lorempixel.com/output/food-h-g-164-166-5.jpg"></div>
<div><img src="http://lorempixel.com/output/food-h-g-164-166-5.jpg"></div>
</div>