为页脚引导程序着色以使其响应

时间:2018-05-15 18:59:00

标签: html css twitter-bootstrap frontend footer

正如您所看到的,在大,中,小屏幕上,页脚具有正确的背景默认颜色(由于panel_footer类),但是,只要三个部分相互堆叠,您就可以看到部分页脚颜色与页面的背景颜色。如何以一种颜色均匀的方式设置页脚的样式?

这里的代码:

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="C:\Users\Gianpa\Desktop\banco di prova coding\sito prova\css\bootstrap.min.css">
  <link rel="stylesheet" href="C:\Users\Gianpa\Desktop\banco di prova coding\sito prova\css\banco prova css.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
  </script>
  <link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
</head>

<body>

  <header>
    <nav id="mainheader" class="navbar navbar-default">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a id="logoheader" class="navbar-brand" href="#"></a>
        </div>

        <!-- general menu for all devices except xs ones -->
        <ul id="generalmenu" class="nav navbar-nav navbar-right visible-lg visible-md visible-sm">
          <li><a href="#"><b>Home</b></a></li>
          <li><a href="#"><b>Servizi</b></a></li>
          <li><a href="#"><b>Contattaci</b></a></li>
          <li><a href="#"><b>Referenze</b></a></li>
        </ul>

        <!-- Menu on the right -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul id="navlist" class="nav navbar-nav hidden visible-xs">
            <li><a href="#"><b>Home</b></a></li>
            <li><a href="#"><b>Servizi</b></a></li>
            <li><a href="#"><b>Contattaci</b></a></li>
            <li><a href="#"><b>Referenze</b></a></li>
          </ul>
        </div>
      </div>
    </nav>
  </header>

  <!-- jumbotron AkA Prague image and main Get On Board write -->
  <div id="mainpage" class="jumbotron img-responsive">
    <div id="intestazione">
      <h1 id="maintitle" class="display-3">Get On Board</h1>
      <p id="subtitle">Learning & Development Consultancy</p>
    </div>
  </div>

  <!--Footer-->
  <footer class="panel-footer">
    <div id="footer" class="container">
      <div class="row">
        <section id="hours" class="col-sm-4">
          <span>Hours:</span><br> Sun-Thurs: 11:15am - 10:00pm<br> Fri: 11:15am - 2:30pm<br> Saturday Closed
          <hr class="visible-xs">
        </section>
        <section id="address" class="col-sm-4">
          <span>Address:</span><br> 7105 Reisterstown Road<br> Baltimore, MD 21215
          <p>* Delivery area within 3-4 miles, with minimum order of $20 plus $3 charge for all deliveries.</p>
          <hr class="visible-xs">
        </section>
        <section id="testimonials" class="col-sm-4">
          <p>"The best Chinese restaurant I've been to! And that's saying a lot, since I've been to many!"</p>
          <p>"Amazing food! Great service! Couldn't ask for more! I'll be back again and again!"</p>
        </section>
      </div>
    </div>
  </footer>


</body>
bar

1 个答案:

答案 0 :(得分:0)

在CSS中,从页脚中删除高度:

#footer {
  height:200px;
}

如您所做的那样定义此高度将调整列堆叠上的默认Bootstrap行为。如果您想维护此属性,请在较大的设备上,在各自的媒体查询上进行定义。

E.g:

@media (max-width: 768px) {
  #footer {
    height: 200px;
  }
}

这是Working Fiddle的链接。

<小时/> PS(与问题无关):您正在导入您的css文件:

<link rel="stylesheet" href="C:\Users\Gianpa\Desktop\banco di prova coding\sito prova\css\bootstrap.min.css">
<link rel="stylesheet" href="C:\Users\Gianpa\Desktop\banco di prova coding\sito prova\css\banco prova css.css">

我建议重命名&#34; banco prova css.css&#34; to&#34; banco_prova_css.css&#34;,并从CDN导入Bootstrap的css,例如:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">