页脚不在内容的末尾

时间:2015-11-25 03:23:56

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

我在尝试让我的页脚实际停留在内容的底部时遇到了麻烦。我尝试了bootstrap粘性页脚示例,但它对我没有用。任何帮助和代码建议表示赞赏。

这是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;
}

1 个答案:

答案 0 :(得分:1)

我认为这是你想要实现的目标? 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>