仅一格的滚动条 [英] Scrollbar in one div only
问题描述
说,例如,我有两个
< body>< div id ="header">我的内容</div>< div id ="main">我的其他内容</div></body>
在CSS中,第一个 div
具有属性 position:fixed;
和 width:100%;
,其他的 div
只是一个包含很多内容的div.
好吧,像往常一样,右侧有一个滚动条.但是此滚动条会影响所有 divs
.我希望滚动条仅影响第二个 div
,可以吗?
我尝试使用 overflow:auto
, overflow:hidden
和 overflow:scroll
进行所有操作,但没有达到我的目标.
编辑:这是我的jsfiddle: http://jsfiddle.net/upcfp/
好,我解决了我的问题,我使用了以下代码:
body {溢出:隐藏;}#主要的{溢出:滚动;}#maincontent {高度:1500px;}
我在#main的内容中指定了高度,这很有效,谢谢大家!
Say, for example, I have two divs
like so:
<body>
<div id="header">
MY CONTENTS
</div>
<div id="main">
MY OTHER CONTENTS
</div>
</body>
The first div
has the attributes position:fixed;
and width:100%;
in CSS, the other div
is just a div with much content inside.
Ok, there is a scrollbar in the right side, as usual. But this scrollbar affects all of the divs
. I want the scrollbar to only affect the second div
, is possible?
I tried everything with overflow:auto
, overflow:hidden
, and overflow:scroll
but I didn't reach my goal...
EDIT: Here my jsfiddle: http://jsfiddle.net/upcfp/
Ok, I solved my problem, I used this code:
body{
overflow: hidden;
}
#main{
overflow: scroll;
}
#maincontent{
height: 1500px;
}
I specified the height in content of #main and it just worked, thanks to everybody!
这篇关于仅一格的滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!