html - 在 Bootstrap 上调整大小时如何将页脚保持在页面底部

标签 html css twitter-bootstrap

我正在从头开始设计我的第一个网站,我正在尝试一次学习所有内容。我已经弄清楚了大部分内容,但是,有几件事我无法弄清楚。 我的问题是,如何在调整页脚尺寸时让页脚贴在页面底部?我在 bootstrap 中工作,当我将页面调整为中小尺寸时,页脚被向上推,远离它应该在的位置。我究竟做错了什么?

这是我的 HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title> Delightful Days Daycare</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<script src="https://use.fontawesome.com/b1366dc4f6.js"></script>

<link rel="stylesheet" type="text/css" href="style.css">

<!-- Header -->
  </head>
<body>

<div class="container-fluid background-box">
    <div class="container background-box ">
        <div class="row">
                <div class="box-1 col-sm-12 col-md-6 col-lg-4"><h2><button class="button button1"><a class="box-text" href="about-us.html">ABOUT US</button></a></h2><img src="img/info.png" class="about-img">Learn more about Mrs. Chris and Delightful Days </div>
                <div class="box-2 col-sm-12 col-md-6 col-lg-4"><h2><button class="button button2"><a class="box-text" href="photos.html">PHOTOS</a></button></h3><img src="img/photos.png" class="photos-img">View our photo gallery</div>
                <div class="box-3 col-sm-12 col-md-6 col-lg-4"><h2><button class="button button3"><a class="box-text" href="calendar.html">CALENDAR</a></button></h3><img src="img/calendar.png" class="cal-img">Stay up to date with our official calendar to view holidays and closed days</div>
            </div>
            <div class="row">
                <div class="box-4 col-sm-4 col-md-6 col-lg-4"><h2><button class="button button4"><a class="box-text" href="contact-us.html">CONTACT US</a></button></h3>
                    <img src="img/phone.png" class="phone-img">Need to get in touch? View our contact page for more information </div>
                <div class="box-5 col-sm-4 col-md-6 col-lg-4"><h2><button class="button button5"><a class="box-text" href="openings.html">OPENINGS</a></h2></button>
                    <img src="img/open.png" class="open-img">View available openings </div>
                <div class="box-6 col-sm-4 col-md-6 col-lg-4"><h2><button class="button button6"><a class="box-text" href="pricing.html">PRICING</a></button></h3>
                    <img src="img/money.png" class="pricing-img">View our pricing page for more information</div>
        </div>
    </div>
</div>
    <!-- Footer -->
    <div class="navbar navbar-default navbar-static-bottom">
        <div class="container-fluid footer">
            <div class="row">
                    <div class="footer-1">
                        <div class="col-sm-4 col-md-4 col-lg-4"></div>
                        <div class="col-sm-4 col-md-4 col-lg-4">
                            <a href="https://facebook.com"><i class="fa fa-facebook fa-4x" aria-hidden="true"></a></i>
                            <a href="https://yelp.com"><i class="fa fa-yelp fa-4x" aria-hidden="true"></a></i>
                            </div>
                            <div class="col-sm-4 col-md-4 col-lg-4"></div>
                    </div>
                <div class="copyright">
                    &#0169; 2016 DELIGHTFUL DAYS DAYCARE. ALL RIGHTS RESERVED
                </div>
            </div>
        </div>
    </div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

</body>
</html>

还有我的 CSS:

html,body {
    color: #8c8c8c;
    font-family: "source sans pro";
    font-style: normal;
    height: 100%;
}

.background-box{
    background-color: #4c4c4c;
    height: 1000.5px;
    color: white !important;
    font-size: 20px;
    text-align: center;
    position: auto;
    display: block;
    margin: auto;

}


.box-1{
    background-color: #FF3D7F;
    width: 330px;
    height: 394px;
    border-radius: 9px;
    /*margin-left: 181px;*/
    margin-top: 50px;
    margin: 2%;
}

.button{
    color: white;
    border:none;
    color: white;
    border-radius: 100px;
    height: 48px;
    width: 178px
}

.button1{
    background-color: #DB1759;
    text-align: center;
}

.button2{
    background-color: #C4C172;
}
.button3{
    background-color: #58A58B;
}
.button4{
    background-color: #B58C43;
}
.button5{
    background-color: #26978F;
}
.button6{
    background-color: #FF6362
}
.box-2{
    background-color: #DAD8A7;
    width: 330px;
    height: 394px;
    border-radius: 9px;
    /*margin-left: 44px;*/
    margin-top: 50px;
    margin: 2%;
}

.box-3{
    background-color: #7FC7AF;
    width: 330px;
    height: 394px;
    border-radius: 9px;
    /*margin-left: 44px;*/
    margin-top: 50px;
    margin: 2%;
}

.box-4{
    background-color: #D7B066;
    width: 330px;
    height: 394px;
    border-radius: 9px;
    /*margin-left: 181px;*/
    margin-top: 46px;
    margin: 2%;
}

.box-5{
    background-color: #3FB8AF;
    width: 330px;
    height: 394px;
    border-radius: 9px;
    /*margin-left: 44px;*/
    margin-top: 46px;
    margin: 2%;
}


.box-6{
    background-color: #FF9E9D;
    width: 330px;
    height: 394px;
    border-radius: 9px;

    /*margin-left: 44px;*/
    margin-top: 46px;
    margin: 2%;
}
.box-text{
    color: white;
       font-family: "Source Sans Pro";
   font-weight: 600;
   font-style: normal;
   font-size: 26px;
}
/*--------Box images------*/
.about-img{
padding-right: 102px;
padding-left: 100px;
padding-bottom: 38px;
position: relative;
padding-top: 43px;
text-align: center;
}


.photos-img{
padding-right: 112px;
padding-left: 112px;
padding-top: 66px;
padding-bottom: 62px;
}
.cal-img{
padding-right: 108px;
padding-left: 109px;
padding-top: 40px;
padding-bottom: 36px;
}

.phone-img{
padding-right: 109px;
padding-left: 109px;
padding-top: 60px;
padding-bottom: 41px;   
}
.open-img{
padding-right: 107px;
padding-left: 108px;
padding-top: 59px;
padding-bottom: 63px;
}

.pricing-img{
padding-right: 108px;
padding-left: 109px;
padding-top: 145px;
padding-bottom: 136px;
}
.footer{
    position: relative;
    height: 150px;
    margin-top:;
}

.footer-1{
    height: 125px;
    padding-top: 36px;
    background: #FF9E9D;
    display: flex;
    text-align: center;
}

.copyright{
    background-color: #4c4c4c;
    height: auto;
    color: white;
    text-align: center;
    font-family: "source sans pro light";
    padding-top: 36px;
    padding-bottom: 33px;
}
.fa{
    color: white;
    margin-left: 40px;
    margin-right: 40px;
}

div.navbar.navbar-default.navbar-static-bottom{
    margin: 0;
}

最佳答案

您需要使用 navbar-fixed-bottom类:

<div class="navbar navbar-default navbar-static-bottom navbar-fixed-bottom"> 
    ...
</div>

关于html - 在 Bootstrap 上调整大小时如何将页脚保持在页面底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38881235/

相关文章:

css - 剪裁在右边缘的 SVG 图稿

jquery - 单击菜单项时防止下拉菜单关闭

php - Bootstrap、导航标签、下拉菜单;如何根据 URI 设置事件选项卡

javascript - 由用户动态生成新页面(Firefox OS)

java - 引入struts2标签后表单未正确对齐

基于 Python Web 的机器人

html - 字体没有出现母鸡上传到 Bluehost

html - <a> 不拉伸(stretch)以填充 <li>

html - 如何根据点击以 Angular 使用css3进行动画处理?

html - 在底部设置页脚,但并不总是在底部