未知高度图片只显示中间一部分

        
<div style="width:300px; height:300px;">
    <img src="dog.jpg" alt=""/>
</div>

div{
            position: relative;
            left:100px;
            top:100px;
            border: solid 1px red;
            overflow: hidden;
        }
        img{
            position: absolute;
            margin: auto;
            top: -9999px;
            right: -9999px;
            bottom: -9999px;
            left: -9999px;
        }

猜你喜欢

转载自blog.csdn.net/weixin_43837268/article/details/85321328