繁体   English   中英

页脚不在内容的结尾

[英]Footer isn't at the end of content

我在尝试使我的页脚真正停留在内容底部时遇到了麻烦。 我尝试了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;
}

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM