使用Bootstrap 4创建居中页脚

时间:2019-01-15 12:01:24

标签: html css twitter-bootstrap bootstrap-4

我正在尝试学习Bootstrap,尤其是Bootstrap 4,但是却为自己的页脚苦苦挣扎。

它有2行,我希望整个内容居中但仍在挣扎。

下面是我目前拥有的HTML

<section class="block-follow-us">
    <div class="container">
        <div class="row align-items-center justify-content-center">
            <div class="col-4 col-md-1 px-0">
                <span class="h5">Follow us:</span>
            </div>
            <div class="offset-1 col-10 offset-md-0 col-md-3 px-0">
                <a href="https://twitter.com/ApolloSciUK?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor" target="_blank" class="fab fa-twitter-square"></a>
                <a href="https://www.linkedin.com/company/apollo-scientific-ltd" target="_blank" class="fab fa-linkedin"></a>
                <a href="https://www.instagram.com/apolloscientific/?hl=en" target="_blank" class="fab fa-instagram"></a>
                <a href="https://www.facebook.com/pages/Apollo-Scientific-Ltd/158179738244405?rf=174620749220860" target="_blank" class="fab fa-facebook-square"></a>
            </div>
        </div>
    </div>
</section>

<footer class="footer">
    <div class="container-fluid">
        <div class="row text-center">
            <div class="col-12">© 2019 - Apollo Scientific Ltd</div>
        </div>
        <div class="row justify-content-center text-center">
            <div class="col-12 col-md-2">
                <a href="/">Terms and conditions</a>
            </div>                        
            <div class="col-12 col-md-2">
                <a href="/">Privacy policy</a>
            </div>                        
            <div class="col-12 col-md-1">
                <a href="/">Careers</a>
            </div>
        </div>
    </div>        
</footer>

在台式机上看起来像下面的样子,但是所有地方都在上面,我一直在努力几个小时才能对其进行排序

enter image description here

虽然手机看起来还不错

enter image description here

1 个答案:

答案 0 :(得分:1)

<section class="block-follow-us">
 <div class="container">
   <div class="row align-items-center justify-content-center">
     <div class="col-lg-12 col-md-12 text-center">
      <span class="h5">Follow us:</span>
       <a href="https://twitter.com/ApolloSciUK?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor" target="_blank" class="fab fa-twitter-square">Link1</a>
       <a href="https://www.linkedin.com/company/apollo-scientific-ltd" target="_blank" class="fab fa-linkedin">Link2</a>
       <a href="https://www.instagram.com/apolloscientific/?hl=en" target="_blank" class="fab fa-instagram">Link3</a>
       <a href="https://www.facebook.com/pages/Apollo-Scientific-Ltd/158179738244405?rf=174620749220860" target="_blank" class="fab fa-facebook-square">Link4</a>
     </div>
   </div>
 </div>
</section>

<footer class="footer">
 <div class="container-fluid">
  <div class="row text-center">
   <div class="col-lg-12">© 2019 - Apollo Scientific Ltd</div>
  </div>
  <div class="row justify-content-center text-center">
   <div class="col-lg-4">
    <a href="/">Terms and conditions</a>
   </div>                        
   <div class="col-lg-4">
    <a href="/">Privacy policy</a>
   </div>                        
   <div class="col-lg-4">
    <a href="/">Careers</a>
   </div>
  </div>
 </div>        
</footer>