我试图在div中垂直居中显示我的图像。我有一组不同高度和宽度的图像。我做了一个320x230的盒子,用来显示里面的图像。较大的图像有溢出:隐藏。但是一些较小的图片有差距,所以我想把它们放在这个网站的中心-> Here
我将此CSS用于包含图像的DIV
.transformations {
max-width:320px;
max-height: 230px;
min-width:320px;
min-height: 230px;
box-shadow: 0 0 50px #0052af;
overflow: hidden;
border: 4px solid #0052af;
}
发布于 2016-02-13 03:31:08
我刚刚做了一些定制,它可以工作了:
<div class="img-wrapper">
<img src="http://img.youtube.com/vi/jofNR_WkoCE/maxresdefault.jpg">
</div>
和css:
.img-wrapper{
position: relative;
overflow:hidden;
height:425px;
}
.img-wrapper img{
position: absolute;
top:-100%; left:0; right: 0; bottom:-100%;
margin: auto;
}
这在Divi wordpress主题上对我很有效。
https://stackoverflow.com/questions/35375581
复制相似问题