这似乎是一个重复的问题,但在我的情况下没有任何效果。
我想将一张图片放在 div
中并完整显示它,直到可能为止。我的图像是一个四 Angular 有边的矩形,我希望根据 div 的大小在 div
中看到它。
.container_img{
border:1px solid red;
margin-top:-14px;
display: table;
margin-top:2px;
width: 709px;
height: 141px;
background-image: url("https://i.imgur.com/VBOZfaY.png");
background-repeat: no-repeat;
}
<div class="container_img"></div>
最佳答案
添加 background-size: 100% 100%;
。请参阅下面的代码片段
.container_img{
border:1px solid red;
margin-top:-14px;
display: table;
margin-top:2px;
width: 709px;
height: 141px;
background-image: url("https://i.imgur.com/VBOZfaY.png");
background-repeat: no-repeat;
background-size: 100% 100%;
}
<div class="container_img"></div>
关于css - 显示图像背景的完整宽度和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55168852/