html - 没有位置 :absolute 没有内容时底部的默认页脚

标签 html css

我需要像页眉内容和页脚这样的布局。

我的要求是...

页脚Div的默认位置在底部,即使content Div中没有内容。

当content Div的内容展开时,整个body(包括header,footer)都需要根据content Div展开

我不需要 position:fixed 用于页脚 Div....

我已经在我的元素中尝试了一些代码......

CSS:

             body
            {
                height:100%;
                margin-left: 0;
                margin-top: 0;
                padding:0;
                width:100%;
                position: relative;
                display:block;
            }
            .container
            {
                display:table;
                width:100%;
                height:100%;
            }
            .header
            {
                top:0px;
                height:75px;
                width:100%;
            }
            .content
            {
                width:100%;
                height:auto;
                position: relative;
            }
            .footer
            {
                top:5px;
                bottom:0px;
                height:45px;
                overflow:hidden;
                width:100%;
            }

代码:

<div>
  <div class="header">
      Header Div
  </div>

  <div class="content">
      Content Div
  </div>

  <div class="footer">
      Footer Div(Need it,default at bottom position)
  </div>
</div>

有什么想法吗?

注意:我还需要在IE中运行这段代码......

最佳答案

将以下样式添加到您的 body 标记或 content div 元素:

    div { 
       min-height: 500px; 
       height:auto !important; 
       height: 500px; 
   }

这是有效的,因为 IE 对待“高度”的方式与应该对待“最小高度”的方式相同。

关于html - 没有位置 :absolute 没有内容时底部的默认页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30012425/

相关文章:

jquery - 使用 jquery 解析表行

javascript - 如何在不使用数据库的情况下显示html页面中提交按钮的表单数据onclick

css - 如何理解这个崩溃报告? SIGSEGV

html - 应用于 tr 的渐变在每个 td 处分别呈现。如何在 tr 上创建水平渐变?

CSS 帮助 : Image renders correctly in FF and Chrome, 不是 IE9

jQuery 动画边框似乎不起作用

javascript - 如何将 html 元素另存为 png

css - 列表项链接的奇怪继承

html - 将图像环绕图像

css - 在 R 中修改 Flexdashboard CSS