如何使DIV滚动而不是BODY? [英] How to make a DIV scrollable instead of BODY?
本文介绍了如何使DIV滚动而不是BODY?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望页面的正文 不可滚动,但正文中的DIV应该可滚动。
我的css文件中有此文件:
I want my page's BODY not to be scrollable but a DIV inside the BODY should be scrollable. I have this in my css file:
body {
overflow:hidden
}
.mainSection {
overflow:scroll
}
但是它不起作用,并且DIV不会变成scrollabel(它仅显示两个DIV禁用的滚动条) !
but it doesn't work and the DIV doesn't become scrollabel (it just shows two disabled scroll bars for the DIV)!
推荐答案
.mainSection
需要具有高度
。否则,浏览器不知道应该考虑溢出
。
.mainSection
needs to have a height
. Otherwise the browser can not know what it should consider overflow
.
这篇关于如何使DIV滚动而不是BODY?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文