css让图片居中显示在手机屏幕上

直接上代码了

<div class="showpic">
    <span></span>
    <img src="" alt="">
</div>

 

样式

.showpic {
    font-size: 0;
    position: fixed;
    top: 0;
    width: 100%;
    height: 100%;
    left: 0;
    background: #4d4d4d;
    z-index: 999;
    text-align: center;
    display: none;
}
.showpic span {
    height: 100%;
    display: inline-block;
    vertical-align: middle;
}
.showpic img {
    vertical-align: middle;
    max-height: 100%;
    z-index: 999;
    max-width: 100%;
    display: inline-block;
}

 

posted @ 2016-07-07 13:31  cqingt  阅读(4645)  评论(0编辑  收藏  举报