gpt4 book ai didi

css - 在静态图像 css 上滚动文本

转载 作者:技术小花猫 更新时间:2023-10-29 11:40:30 24 4
gpt4 key购买 nike

如何使背景图像保持静态并仅滚动文本?

#wrapper{
height: 100%;
width: 100%;
background-image: url('background.jpg');
background-size: 100%;
background-position: fixed;
}

这是我的背景样式,但它仍然滚动,在文本到达底部之前在下方留下空白。我已经在谷歌上搜索了一个小时了。这是我第一次尝试使用 css,所以请不要对我太苛刻。

最佳答案

<style>
#test {
background-image: url(./images/grad.gif);
background-attachment: fixed;

/*
the three following items below do the following:
a) fix the width and height of the containing div
to be smaller than the width and height of the content.
b) we set the overflow style so that when the content is
bigger than the containing element scroll bars appear
to allow users to scroll the element contents.
*/
height:200px;
width:300px;
overflow:scroll; }
</style>

<div id="test">
test test test test test test test test test test test <br/>
test test test test test test test test test test test <br/>
test test test test test test test test test test test <br/>
test test test test test test test test test test test <br/>
<div style="border:3px solid white; margin:20px; width:80%">
test test test test test test test test test <br/>
test test test test test test test test test <br/>
test test test test test test test test test <br/>
test test test test test test test test test <br/>
</div>
test test test test test test test test test test test <br/>
test test test test test test test test test test test <br/>
test test test test test test test test test test test <br/>
test test test test test test test test test test test <br/>


</div>

更多信息:http://www.codertools.com/css_help_guide/css_background-attachment.aspx

关于css - 在静态图像 css 上滚动文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22702728/

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