`我正在尝试运行以下代码,但我的图像对于我的 div 来说总是太大,所以它部分出现了
.display-box
{
width:80vmin;
padding:50px 40px;
background-image: url("paper.gif");
background-size: cover;
position: absolute;
width: 80vmin;
height:80vmin;
padding:50px 40px;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
我尝试使用 background-size: cover 和 background-size: contain 以及 no-repeat center center fixed; 但它没有用。`
如果你不需要保持宽高比那么你可以使用
background-size: 100% 100%;