[英]how can i make the background image for <body> adapt?
newbie here.新手在这里。 I've set a background image for body but when the window size changes too much the image does not fit.我已经为 body 设置了背景图像,但是当 window 大小变化太大时,图像不适合。 what can i do to eliminate white spaces?我能做些什么来消除空格? (I apologize if the question is silly, but not knowing what the problem is, I struggle to find a solution. thanks for the attention!) (如果问题很愚蠢,我很抱歉,但不知道问题是什么,我很难找到解决方案。感谢您的关注!)
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-image: url("img/background.jpg");
background-size: cover;
background-repeat: no-repeat;
}
You can use the background-attachment and background-position to fill the background.您可以使用 background-attachment 和 background-position 来填充背景。
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: url("img/background.jpg");
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.