简体   繁体   English

如何使用引导程序使页脚响应

[英]How to make footer responsive using bootstrap

I'm having a problem aligning the footer. 我在调整页脚时遇到问题。 At mobile the copyright part is not centered. 在移动设备上,版权部分未居中。 at ipad it's below the footerlinks. 在ipad上,它位于页脚链接的下方。 I want it at center at ipad and mobile view while on web it would be on the left side while footerlinks on the right in one row. 我希望它在iPad和移动设备视图的中心位置,而在Web上,它应该位于左侧,而脚注链接则位于右侧。 I'm using bootstrap 我正在使用引导程序

 .copyright { overflow: hidden; background: #128cbf ; float: left; } .copyright p { letter-spacing: 0.1em; font-size: 0.50em; color: #ffffff; font-weight: 300; } .footerlinks{ float: right; } .footerlinks, .footerlinks a { letter-spacing: 1px; text-decoration: none; text-transform: uppercase; font-size: 0.5em; color: #ffffff; padding: 0 5px; font-weight: 200; } /* Tabled Portrait */ @media screen and (max-width: 768px) { #primary { width:100%; } #secondary { width:100%; margin:0; border:none; } .footerlinks { text-align: center; font-size: 1.5em; padding: 0 20px;} .copyright { font-size: 1em; } } 
  <div class="row"> <div class="footerlinks text-center .col-sm-6 .col-md-5 .col-lg-6"> <p><span><a href="#">text</a></span>&middot;<a href="#">text</a>&middot;<a href="#">text</a>&middot;<a href="#">text</a>&middot;<a href="#">text</a>&middot;<a href="#">text</a>&middot;<a href="#">text</a></p> </div> <div class="copyright .col-sm-6 .col-md-5 .col-md-offset-2 .col-lg-6 .col-lg-offset-0"> <p>&copy; Copyright &middot; All Rights Reserved</p> </div> </div> 

You need to remove the . 您需要删除. from all your classes in your html or otherwise they wan't apply to your code. 从您的html中的所有类中获取,否则它们将不适用于您的代码。 You only need the . 您只需要. when writing css. 当写CSS。

This is how it should be: 这应该是这样的:

 .copyright { overflow: hidden; background: #128cbf ; float: left; } .copyright p { letter-spacing: 0.1em; font-size: 0.50em; color: #ffffff; font-weight: 300; } .footerlinks{ float: right; } .footerlinks, .footerlinks a { letter-spacing: 1px; text-decoration: none; text-transform: uppercase; font-size: 0.5em; color: #ffffff; padding: 0 5px; font-weight: 200; } /* Tabled Portrait */ @media screen and (max-width: 768px) { #primary { width:100%; } #secondary { width:100%; margin:0; border:none; } .footerlinks { text-align: center; font-size: 1.5em; padding: 0 20px;} .copyright { font-size: 1em; } } 
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <div class="row"> <div class="footerlinks text-center col-sm-6 col-md-5 col-lg-6"> <p><span><a href="#">text</a></span>&middot;<a href="#">text</a>&middot;<a href="#">text</a>&middot;<a href="#">text</a>&middot;<a href="#">text</a>&middot;<a href="#">text</a>&middot;<a href="#">text</a></p> </div> <div class="copyright col-sm-6 col-md-5 col-md-offset-2 col-lg-6 col-lg-offset-0"> <p>&copy; Copyright Tongle 2013-2016 &middot; All Rights Reserved</p> </div> </div> 

You could simply use the media query for small and extra small devices like: 您可以简单地将媒体查询用于小型和超小型设备,例如:

@media screen and (max-width: 991px){
    .footerlinks, .copyright{
        text-align: center;
    }
}

Other option is to use the Bootstrap responsive utility classes. 另一种选择是使用Bootstrap响应实用程序类。 You can check out this page to learn more about the device break points and live example of responsive utility classes- http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/bootstrap-grid-system.php 您可以查看此页面以了解有关设备断点和响应实用程序类的实时示例的更多信息-http : //www.tutorialrepublic.com/twitter-bootstrap-tutorial/bootstrap-grid-system.php

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

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