scroll bar on div with overflow:auto and percentage height

独自空忆成欢 提交于 2019-12-01 04:08:12

In answer to your question, yes overflow:auto will work, but you will need height: 100% on the HTML tag as well:

html,body {    
    height:100%;
    margin: 0;
}
#header {
    height: 100%;
}
#content {
    height: 100%;
    overflow: auto;
}

The way your markup is structured though will produce two divs both the same height as the viewport one on top of the other. Is that what you intended?

If so here is a jsFiddle that illustrates your example. I've tweaked the markup and added additional content so that the content div overflows as you require.

http://jsfiddle.net/chrissp26/WsNjm/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!