答案 0 :(得分:0)
让您的缩略图响应。 css属性.img-responsive
使图像响应(将很好地缩放到父元素)。
答案 1 :(得分:0)
这是一个可行的示例
这是html
<p>Background image:</p>
<div class="zoom-bg"></div>
<p>Using nested image and <code>object-fit</code>:</p>
<div class="zoom-img">
<img src="https://placeimg.com/300/200/arch">
</div>
这是css
.zoom-bg {
width: 300px;
height: 200px;
overflow: hidden;
}
.zoom-bg:before {
content: '';
display: block;
width: 100%;
height: 100%;
background: url(https://placeimg.com/300/200/nature) no-repeat center;
background-size: cover;
transition: all .3s ease-in-out;
}
.zoom-bg:hover:before {
transform: scale(1.2);
}
.zoom-img {
width: 300px;
height: 200px;
overflow: hidden;
}
.zoom-img > img {
object-fit: cover;
width: 100%;
height: 100%;
transition: all .3s ease-in-out;
}
.zoom-img:hover > img {
transform: scale(1.2);
}
中查看工作示例