html - 让包装器将页脚向下推

标签 html css

我在获取 <div id="wrapper"> 中的元素时遇到问题压低我的页脚。此刻 wrapper 流入页脚。我该如何解决?

这是我的 HTML:

<div id="header">
</div>
<div id="wrapper">
  <div id="findcontent">
    <div id="criteriabar">
    </div>
    <div id="searchresults">
    </div>
  </div>
</div>
<div id="footer">
</div>

使用以下 CSS:

#header {
    position: relative;
    display: block;
    height:65px;
}

#wrapper {
    right: 0;
    left: 0;
    position: relative;
    padding: 0;
}

#findcontent {
    position: relative;
    min-width: 960px;
    min-height: 400px;
    margin: 0 20px;
}

#criteriabar {
    position: relative;
    float: left;
    width: 190px;
    border-right: 1px solid #CCC;
    height: 100%;
    padding-right: 20px;
    left: 30px;
    top: 30px;
}

#searchresults {
    position: relative;
    width: 770px;
    left: 40px;
    right: 10px;
    top: 30px;
}

#footer {
    display: block;
    zoom: 1;
    position: relative;
    overflow: hidden;
    border-top: solid 1px #CCD9FF;
    margin: 20px 0px 10px;
}

更新:添加class="clearfix"单独没有这样做。我还必须更改 topmargin-top用于 <div id="find content"> 内的 float 元素.

最佳答案

您的包装器内有 float div,需要清除。您有两个选择:

选项 1:

#wrapper {
    right: 0;
    left: 0;
    position: relative;
    padding: 0;
    overflow:hidden; /* This guy */
}

选项 2:

//CSS

.clear {
    clear: both;
}

//HTML

<div id="wrapper">
  <div id="findcontent">
    <div id="criteriabar">
    </div>
    <div id="searchresults">
    </div>
  </div>
  <div class="clear"></div>

关于html - 让包装器将页脚向下推,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7911491/

相关文章:

javascript - 来自 Firefox 的错误 : MIME type (“text/plain” ) mismatch (X-Content-Type-Options: nosniff)

html - 在实体化的页脚内移动上方的文本

android - 将 mix-blend-mode 设置为除 "normal"之外的任何值都会隐藏 Android 9 上 Chrome 中的元素

html - 无法在 TD 标记中将图像固定在顶部

html - CSS:下拉选项文本颜色在 Mac OS X 上不起作用

html - 在 chrome 开发工具中找不到 404 错误 CSS 文件

javascript - css - 扩展导航栏防止点击输入

javascript - 闪烁某个图像

html - Wordpress - 删除默认样式

html - 下面的 CSS 可以进一步简化吗?