我正在尝试使用文本作为网站的背景图片 - 如果文本自动重排就没问题,但我试图不滚动页面 - 所以在我身上我有溢出:隐藏,效果很好,除非我的内容 div 变得太长,此时它也被隐藏了。
有没有办法让“背景”层溢出:隐藏,同时让我的内容在必要时流动? (我已经尝试过明显的溢出:隐藏在#background 上)
<body>
<div id="content">
All my content
</div>
<div id="background">
<p>'I told some of yo... lots of text</p>
</div>
</body>
是目前的基本页面格式,css是:
body {overflow:hidden;}
#background {
position:absolute;
top:-20px;
right:-20px;
bottom:-20px;
left:-20px;
overflow:hidden;
z-index:-1;}
#content {
width:840px;
text-align:left;
margin-top:30px;
margin-left:auto;
margin-right:auto;
height:auto;
overflow:visible;}
最佳答案
固定 #background
位置并设置 overflow:hidden 到它,而不是正文。
body {}
#background {
position:fixed;
top:0;
left:0;
width:95%;
height:95%;
overflow:hidden;
z-index:-1;
}
关于html - 在 html 页面上使用文本而不是图像作为背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7046193/