gpt4 book ai didi

css - 如何在背景保持不变的情况下使 div 内容滚动

转载 作者:行者123 更新时间:2023-11-28 10:54:58 25 4
gpt4 key购买 nike

好吧,我的意思是,我希望我的背景图像保留下来,而 div 中的内容随着添加更多内容而滚动。

看我不想让它滚动 http://codepen.io/anon/pen/gLCns/

看到的有点像 codepen 上的内容,你可以在每个窗口中滚动,但它不会只在那个窗口中流动

最佳答案

您可以使用 background-attachment: fixed; 属性来修复背景图像。

html { 
width: 100%;
height: 100%;
background: url(http://lorempixel.com/400/400) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

.content{
position: absolute;
background-color: rgba(255,255,255,0.7);
width:50%;
height:1020px;
left:20px;
top:20px;
}

这是一个 Demo.

关于css - 如何在背景保持不变的情况下使 div 内容滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22647283/

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