【问题标题】:Why add padding to the main div and not its parent div, wrap?为什么添加填充到主 div 而不是它的父 div,换行?
【发布时间】:2011-06-12 02:01:29
【问题描述】:

这是简单的html:

<div id="wrap">

<div id="main">

</div>

</div>

<div id="footer">

</div>

这是css:

* {margin:0;padding:0;} 

 html, body {height: 100%;}

 #wrap {min-height: 100%;}

 #main {overflow:auto;
    padding-bottom: 150px;}

 #footer {position: relative;
    margin-top: -150px; 
    height: 150px;
    clear:both;}

我的问题是将填充底部添加到#wrap div而不是它的#main div不是更有意义吗?

如果您想知道,这与页脚始终位于底部并且在调整页面大小时不与之前的内容重叠有关。

【问题讨论】:

  • 您尝试过您建议的方式吗?它可能会回答你的问题
  • 我做到了,它没有使页脚成为页面上的最后一件事,但我仍然不知道为什么会这样?

标签: css xhtml layout sticky-footer


【解决方案1】:

我猜你可能会在使用盒子模型时遇到麻烦,因为填充会增加 #wrap 的高度——你试过了吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    • 1970-01-01
    • 2012-11-10
    • 2021-05-15
    • 1970-01-01
    • 2019-07-14
    相关资源
    最近更新 更多