页面内容不能滚动页面(无iframe)
由于我不知道正确的术语,所以我很难说出这个问题。我正在尝试创建一个网站,以便在滚动主要内容时不会滚动页面。我希望主要内容在页面中间的某个地方结束,以免覆盖我的“固定”背景图像。但我不想要一个iframe。换句话说,它看起来有点像iframe,但它应该由主滚动条控制。页面内容不能滚动页面(无iframe)
无论如何,我希望这是有道理的。我会很感激你的建议。
可以使用两个<div>
s,它将覆盖顶部和底部,以便您的文本可以放在它们的下面。
+----------------+
|+--------------+|
|| top ||
|+--------------+|
| your text |
| text |
|+--------------+|
|| bottom ||
|+--------------+|
+----------------+
在z-index
,所述top
和bottom
将超过主层,并且它们将被定位fixed
到左上角和左下角。
您是否已经使用background-attachment: fixed;
?
或overflow-y: scroll;
与div?
这将创建一个新的滚动条,以他的DIV,我相信 – 2011-04-11 23:13:04
的确。固定背景是要走的路。 – Calum 2011-04-11 23:15:43
你想在你的HTML块中显示滚动条,对吧?尝试使用CSS溢出属性。
参考:www.w3schools.com/css/pr_pos_overflow.asp
在您的网页代码试试这个:
<style type="text/css">
<!--
div.scroll {
height: 200px;
width: 300px;
overflow: auto;
border: 1px solid #666;
background-color: #ccc;
padding: 8px;
}
-->
</style>
<div class="scroll">
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
<p>This is a scrolling are created with the CSS property overflow.</p>
</div>
这是你正在试图做的?
不,我试图让只有内容条目使用主滚动条滚动。我不想在页面中间有一个滚动条。这里是我正在使用的代码的链接。 http://jsfiddle.net/callcan/9Nu5c/ – Candice 2011-04-13 22:33:40
谢谢你的所有意见! iuliux,是的,这是我想要做的。预计我只想使用主滚动条来滚动我的内容条目。我是新手,在你离开我的链接之前,我不知道JS的小提琴!谢谢。无论如何,我已经在这里添加了我的代码:http://jsfiddle.net/callcan/9Nu5c/ – Candice 2011-04-13 18:54:34
但它使用主滚动条进行滚动。你能不能尝试清理一下你的代码,所以你只留下了相关的部分,因为很难合作,很杂乱。抱歉。 – 2011-04-14 18:55:40
对不起。我清理了我的代码。我会尽力与你在上一篇文章中提出的建议一起工作。这是我需要的,但我想我只是在执行时遇到问题。我对此仍然很陌生。 – Candice 2011-04-14 22:36:26