div与全屏幕滚动
问题描述:
如何使滚动的全屏幕div?此代码的工作,但scroollbar没有出现:div与全屏幕滚动
HTML:
<div id="full_screen"></div>
CSS:
#full_screen {
position: fixed;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 10;
}
答
使用overflow:scroll;
显示滚动。由于滚动的默认行为是overflow:auto;
。
#full_screen {
position: fixed;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 10;
background:red;
overflow:scroll;
}
.content{
width: 1000px;
height: 1000px;
}
<div id="full_screen"><div class="content"></div></div>
答
<div id="full_screen"></div>
这里是更新CSS。当div#全屏幕中的内容超过其可以包含在屏幕中时,则会出现滚动。
#full_screen {
position: fixed;
width: 100%;
height: 100%;
left: 0;
right:0;
bottom:0;
top: 0;
z-index: 10;
overflow-y: scroll;
}
尝试添加溢出:滚动;到你的CSS –