如何制作header/body/footer 'popup'具有可变高度主体的Div
How to make header/body/footer 'popup' div with variable height body?
我制作了一个弹出式div,它看起来像我网页上的一个经典窗口,可以最小化/调整大小/移动。
我需要它有一个25像素高的页眉,一个50像素高的页脚,然后窗口的主体总是采用"rest",这是可变的,因为窗口可以调整大小。该窗口的主体动态更新DOM,其中可以添加元素。如果添加了足够多的元素,它们的总高度超过了分配给窗口主体的高度,那么这个主体区域应该开始滚动,当用户滚动时,页脚始终保持在原地-它只是主体内容在滚动。
如何使用CSS, jQuery和它的工作与IE8?
代码应该看起来像这样,基本上:
<div id="wrap">
<div id="header">
... 25 px high space fixed to the top
</div>
<div id="body">
... stretches to fill the space available height/width ...
... scrollbars available when the body content exceeds height available ...
... jQuery allows user to resize the whole window, so this body should always fill ...
</div>
<div id="footer">
... 50px footer with controls, must always be fixed to bottom of window ...
... must never move no matter if the user scrolls the body ...
</div>
</div>
是否可以实现跨浏览器工作?IE8+, Firefox, Chrome?
试试这里的演示http://jsfiddle.net/XfPAG/4/。这个想法是使用绝对位置:
HTML<div id="wrap">
<div id="header">
... 25 px high space fixed to the top
</div>
<div id="body">
... stretches to fill the space available height/width ...
... scrollbars available when the body content exceeds height available ...
... jQuery allows user to resize the whole window, so this body should always fill ...
</div>
<div id="footer">
... 50px footer with controls, must always be fixed to bottom of window ...
... must never move no matter if the user scrolls the body ...
</div>
</div>
CSS: #wrap, #header, #body, #footer {
position: absolute;
left: 0;
right: 0;
}
#wrap {
top: 0;
bottom: 0;
}
#header {
height: 25px;
top: 0;
}
#footer {
height: 50px;
bottom: 0;
}
#body {
top: 25px;
bottom: 50px;
overflow: auto;
}
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- ExtJS——在展开/折叠时调整面板高度
- 分析高度属性时出现意外值{{specs.height}}.index.html
- 单击页面上的链接后高度发生变化
- 主体上的addEventListener('mousemove',..)-有多糟糕
- 不加载宽度和高度的角度pintura
- 查找元素高度,包括边距
- 如何自动调整标签的高度以适应内容
- Javascript高度问题
- 使用JavaScript根据窗口/视口的高度动态调整图像大小
- 如何计算每个元素's的高度,并将这些值用作函数中的变量
- 如果宽度是百分比,如何设置以px为单位的图像高度
- 通过jquery设置最小高度
- 文档就绪提供了错误的选择器高度
- 如何根据主体高度动态更改元素边距顶部
- CSS主体100%高度,必要时溢出
- 将元素高度设置为等于主体高度减去 170px
- 100%的高度在主体和html创建滚动问题
- 调整jqxWindow的大小时,窗口主体的宽度和高度不变
- 如何制作header/body/footer 'popup'具有可变高度主体的Div