CSS 实现图片 水平居中 垂直居中 自适应居中

[scode type="share"]

<!--html-->
<div class="warp">
  <img src="/test.png" class="img">
</div>

[/scode]

Css

[scode type="green"]

.warp {
    width: 500px;
    height: 350px;
    line-height: 350px;
    text-align: center;
    background: #ccc;
}
.img{
    display: inline-block;
    width: auto;
    height: auto;
    max-width: 500px;
    max-height: 100%;
    vertical-align: middle;
}

[/scode]

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享