当我在笔记本电脑中运行代码时,img将以全屏显示。但是,当我在更大的屏幕尺寸上运行它时,它会变成两倍:enter image description here
这是我使用的CSS代码:
body {
background: url(pic.jpg);
background-size: cover;
background-position: center;
font-family: Lato;
color: white;
}
html {
height: 100%
}
有人可以帮我解决这个问题吗,即img在任何屏幕尺寸下都应全屏显示?
最佳答案
在代码中添加以下样式,以避免重复图像:
background-repeat:no-repeat;
关于html - 任何屏幕尺寸下的完整图像尺寸,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51476216/