jojuniori
10/24/2016 - 6:21 PM

CSS图片完美垂直居中的实现方法:display:table\table-row\table-cell.html

<style type="text/css">
    .container {
        width: 300px;
        height: 400px;
        margin: 50px auto;
        border: 1px solid #ccc;
        display: table;
    }

    .img {
        text-align: center;
        vertical-align: middle;
        display: table-cell;
    }

    img {
        width: 260px;
        height: 350px;
    }
</style>
<body>
    <div class="container">
        <div class="img">
            <img src="your_image.jpg">
        </div>
    </div>
</body>