gpt4 book ai didi

HTML 正文背景图片未覆盖所有页面

转载 作者:太空宇宙 更新时间:2023-11-04 04:44:54 25 4
gpt4 key购买 nike

我正在尝试将背景图片设置为整个 html 页面,但我每次都失败了。它没有拉伸(stretch)。这是我的 css 和 html 代码:

CSS 代码:

body {
background-image:url(body_background.png);
background-repeat: no-repeat;
background-size: 100% 100%;
width:1200px;
margin:0 auto;
}

#main_container_div {
padding: 0px;
width: 1000px;
margin-top: 30px;
margin-left: 150px;
}

#div2 {
float: left;
width: 250px;
height: 600px;
margin-top: 0px;
margin-right: 0px;
background-repeat: no-repeat;
}
#div3 {
position: relative;
float: left;
width: 750px;
height: 500px;
margin-top: 50px;
overflow: hidden;
}

HTML 正文:

<body>    
<div id="main_container_div">
<div id="div3">
</div>
<div id="div2">
</div>
</div>
</body>

您可以尝试使用尺寸为 1366x768 的图像。我也在 1366x768 分辨率上尝试这个。请注意,这个问题在这个或更高的分辨率下是可见的。感谢您的帮助..

最佳答案

尝试 background-size: cover 在你的 CSS 中

background-size:cover;

关于HTML 正文背景图片未覆盖所有页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14705710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com