html - 页脚不在内容的末尾

标签 html css twitter-bootstrap twitter-bootstrap-3

我在尝试让页脚实际停留在内容底部时遇到问题。我尝试了 bootstrap sticky footer 示例,但它对我不起作用。感谢任何帮助和代码建议。

这是 CSS。这是一个实时版本,可以查看它在做什么。 https://jsfiddle.net/2f9zsu7d/2/

body {
    background-color: #02060A;
}

#header {
    width: 950px;
    height: 200px;
}

.row.no-pad {
    margin-right:0;
    margin-left:0;
}

.row.no-pad > [class*='col-'] {
    padding-right:0;
    padding-left:0;
}

/*!
 * Start Bootstrap - Simple Sidebar HTML Template (http://startbootstrap.com)
 * Code licensed under the Apache License v2.0.
 * For details, see http://www.apache.org/licenses/LICENSE-2.0.
 */
#wrapper {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    width: 100%;
    margin-bottom: -60px;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

#sidebar-wrapper {
    position: absolute;
    min-height: 100%;
    width: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #fff;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

#page-content-wrapper {
    position: absolute;
    width: calc(100% - 250px);
    min-height: 100%;
    padding: 15px;
    left: 250px;
    background-color: #fff;
    border-left: 1px solid #080D11;
}

/* Sidebar Styles */
.sidebar-nav {
    position: absolute;
    top: 0;
    width: 250px;
    margin: 0;
    padding: 0;
    list-style: none;
    color: #575959;
}

.sidebar-nav li {
    text-indent: 20px;
    line-height: 40px;
}

.sidebar-nav li i {
    text-indent: 0px;
}

.sidebar-nav li a {
    display: block;
    text-decoration: none;
    color: #575959;
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
    -o-transition: all 0.5s;
    transition: all 0.5s;
}

.sidebar-nav li a:hover {
    text-decoration: none;
    color: #CF9139;
    padding-left: 35px;
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
    text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
    background-color: #050A0E;
    height: 50px;
    font-size: 18px;
    line-height: 50px;
    color: #CF9139;
    border-bottom: 1px solid #CF9139;
}

/*
*End of navigation
--------------------------------
*/

/*Content*/
.content-wrapper {
    background-color: #02060A;
    width: 100%;
    min-height: 100px;
    height: auto;
    margin-bottom: 20px;
    border: 1px solid #080D11;
}

.content-wrapper .title {
    height: 50px;
    line-height: 50px;
    font-size: 18px;
    text-indent: 25px;
    background-color: #050A0E;
    color: #CF9139;
    border-bottom: 1px solid #CF9139;
}

.content-wrapper .title .avatar {
    position: relative;
    border: 1px solid #CF9139;
    height: 60px;
    width: 60px;
    float: left;
    background-color: #000;
    top: -5px;
    left: 15px;
}

.content-wrapper .message {
    margin: 15px;
}

.content-wrapper .message p {
    color: #575959;
}

.content-wrapper .message a {
    text-decoration: underline;
    color: #939595;
}

.content-wrapper .message .subTitle {
    position: relative;
    font-size: 14px;
    line-height: 14px;
    width: 100%;
    border-top: 1px solid #575959;
    bottom: 0;
    padding-top: 5px;
    color: #575959;
}

.content-wrapper .message .subTitle a {
    text-decoration: underline;
    color: #939595;
}

/*Footer*/
#push {
    height: 60px;
}

#footer {
    width: 100%;
    height: 60px;
    background-color: #02060A;
    border-top: 1px solid #080D11;
}

#footer p {
    color: #575959;
}

#footer .footer_wrapper {
    height: auto;
    margin: 15px;
}

#footer .footer_wrapper .aff {
    float: right;
    margin-left: 5px;
}

#footer .footer_wrapper .link {
    float: right;
    margin-left: 5px;
}

#footer .footer_wrapper .ipv6 {
    float: right;
}

最佳答案

我认为这就是您想要实现的目标? https://jsfiddle.net/2f9zsu7d/3/

如果是,则绝对将元素定位在它之前的容器中。这意味着容器将没有与之关联的高度,除非您在其上专门定义了一个高度。我认为您可能想要使用的方法类似于下面的方法。

*, *:before, *:after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}
.body {
  background: #efeffe;
}
.header {
  height: 100px;
  background: #bbb;
}
.sidebar {
  width: 250px;
  float: left;
  background: tomato;
  height: 100px;
}
.content {
  margin-left: 275px;
  background: #efefef;
  height: 100px;
}
.footer {
  background: #ddd;
  height: 25px;
}
<div class="body">
  <div class="header">
    <p>This is your header container</p>
  </div>
  <div class="contentWrapper">
    <div class="sidebar">
      <p>This sidebar is floated and has a hard width of 200px.</p>
      </div>
    <div class="content">
      <p>This box is not floated, however is has a margin-left greater than the width of the sidebar.</p>
    </div>
  </div>
  <div class="footer">
    <p>This is your footer</p>
   </div>
</div>

关于html - 页脚不在内容的末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33907970/

相关文章:

css - 将满足的 div 内的 div 扩展到全宽

python - 如果使用 XPath 是 Scrapy 中其他节点的父节点,如何从子节点获取文本

行的 HTML 表格布局

jquery 'hover mouseover' 函数跳跃

javascript - Bootstrap 响应 : Show multiple div in collapse mode

html - 在下面的示例中,我如何排列我的文本和我的按钮?

php - 低容量开源留言板有建议吗?

css - Avada Wordpress 主题,无法调整 Logo 大小(使用咖啡馆演示内容)

html - 始终在适当的位置显示悬停文本

javascript - 拖放以弹出添加预填充的新模态表单?