【问题标题】:Default footer in bottom when no content without position:absolute无内容时底部默认页脚:绝对
【发布时间】:2015-05-05 11:31:06
【问题描述】:

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

我的要求是……

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

当内容Div的内容展开时,整个正文(包括页眉、页脚)需要在内容Div的基础上展开

我不需要位置:固定为页脚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中运行这段代码......

【问题讨论】:

标签: html css


【解决方案1】:

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

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

这是可行的,因为 IE 对待“高度”的方式应该是对待“最小高度”的方式。

【讨论】:

  • 查看我编辑的答案。如果您的问题得到解决,请不要忘记投票并将其标记为已接受
猜你喜欢
  • 2019-06-14
  • 2016-03-20
  • 1970-01-01
  • 2014-04-14
  • 2015-09-02
  • 2016-07-11
  • 1970-01-01
  • 2015-11-14
  • 2017-02-09
相关资源
最近更新 更多