Materalize页脚不会停留在底部?

时间:2018-05-07 07:46:05

标签: html css materialize

我在我的网页上使用了materialise,由于某种原因,即使我使用Materialize自己推荐的CSS,页脚也不会停留在底部。我错过了什么吗?

这是CSS:

body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

这是页脚的HTML:

<footer class="page-footer green lighten-1">
<div class="container">
    <div class="wrapper">

      <!--   Icon Section   -->
      <div class="row">
        <div class="col s12 m4">
          <div class="icon-block">
            <h4 class="green-text" id="mailIcon"><i class="material-icons">mail</i></h4>
            <p class="white-text">info@storytourist.com</p>
          </div>
      </div>

        <div class="col s12 m4">
          <div class="icon-block">
            <h4 class="green-text" id="adressIcon"><i class="material-icons">map</i></h4>
            <p>Veldrom AB, Anckargripsgatan 3, 211 19 Malmö, Sweden</p>
          </div>
        </div>

        <div class="col s12 m4">
          <div class="icon-block">
            <h4 class="green-text" id="phoneIcon"><i class="material-icons">phone</i></h4>
            <p class="white-text">+46 720 427 346</p>
          </div>
        </div>
      </div>
</footer>

2 个答案:

答案 0 :(得分:1)

问题已解决。

没有使用主标签。

<body>

  <main>  //added 
     <div class="container">
     </div>
  </main>

  <footer> this is my footer </footer>
<body>

答案 1 :(得分:0)

将页脚贴在按钮上将此添加到您的css中:

.page-footer{
    position: fixed;
   left: 0;
   bottom: 0;
   width: 100%;
   background-color: red;
   color: white;
   text-align: center;
}

完整的CSS将是:

body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}


.page-footer{
    position: fixed;
   left: 0;
   bottom: 0;
   width: 100%;
   background-color: red;
   color: white;
   text-align: center;
}

Reference