gpt4 book ai didi

html - 我如何设置固定背景并在 css 中滚动?

转载 作者:行者123 更新时间:2023-11-28 17:51:29 24 4
gpt4 key购买 nike

我如何设置固定背景并在 css 中滚动???而且我一直在尝试设置一个背景来覆盖所有维度,因为我总是以模糊的背景结束:(

我在这方面相对较新,所以请不要评判我,这是我的 CSS: body #bg { 宽度:100%; 高度:100%; position:absolute; 左:0px; 顶部:0px; z-索引:0; 背景附件:固定;

.stretch
{
width:100%;
height:100%;
background-attachment:fixed;
}

最佳答案

像这样:

此 oe 已修复,将 body 设置为 100% 以全屏显示:http://jsfiddle.net/X8Z2v/4/

这个正在滚动:http://jsfiddle.net/X8Z2v/5/

 html, body {
height:3000px;
margin:0;
padding:0;
}
.stretch {
position: absolute;
left:0;
right:0;
top:0;
bottom:0;
background-image: url(http://www.placehold.it/2000x1000);
background-size: cover;
background-repeat: no-repeat;
background-position: center;
background-attachment: scroll;
}

HTML

<div class="stretch"></div>

关于html - 我如何设置固定背景并在 css 中滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22231643/

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