简体   繁体   English

用于超小屏幕尺寸设备的引导程序列

[英]Bootstrap columns for extra small screen size devices

I am trying to make a responsive columns using bootstrap. 我正在尝试使用引导程序来创建响应列。 In desktop and large screen sizes it should have 4 columns. 在台式机和大屏幕尺寸中,它应该有4列。 In Tab viewpots it should have 3 columns and in extra small viewports it should be 2 columns. 在“选项卡”视口中,它应具有3列,而在较小的视口中,则应为2列。

This is my Markup - 这是我的标记-

 <nav class="page-footer-nav row"> <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3"> <a href="">Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> </div> <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3"> <a href="">Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> </div> <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3"> <a href="">Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> </div> <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3"> <a href="">Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> </div> </nav> 

This markup working properly in small, desktop and large screen sizes. 此标记可在小型,台式机和大屏幕尺寸中正常工作。 But it has a mess in extra small size. 但是它的尺寸太小了。 Check this JSBIN for better understanding. 检查此JSBIN以获得更好的理解。

This is a screen shot in xs device size- 这是xs设备尺寸的屏幕截图-

在此处输入图片说明

Clear floats (with the .clearfix class) at specific breakpoints to prevent strange wrapping with uneven content: 在特定的断点处清除浮点数(使用.clearfix类),以防止内容不均匀的奇怪包装:

In the Bootstrap documentation for the grid system they advise you to add a new div in between the columns to help it understand where the columns should clear. 他们建议您在网格系统的Bootstrap文档中建议您在各列之间添加新的div,以帮助其了解应清除列的位置。 The div should have a clearfix class so the columns clear to the left and one of the helper classes so you can target a specific viewport. div应该具有clearfix类,因此列在左侧和辅助类中都可以清除,因此您可以定位特定的视口。

LIVE DEMO 现场演示

and add this between the two parts : 并将其添加到两个部分之间:

  • you need to add a clearfix <div class="clearfix visible-xs "></div> to avoid this issue in xs devises 您需要添加一个clearfix <div class="clearfix visible-xs "></div>以避免在xs装置中出现此问题

Like so : 像这样:

<nav class="page-footer-nav row">
      <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3">
        <a href="">Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
      </div>
      <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3">
        <a href="">Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
      </div>

    <div class="clearfix visible-xs"></div> // < --- add this to fix the issue

      <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3 ">
        <a href="">Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
      </div>
      <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3 ">
        <a href="">Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
        <a href="">Sub Menu Item</a>
      </div>
    </nav>

 $('.page-footer-nav').each(function() { $(this).children('.footer-nav-section').matchHeight(); }); 
 <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.matchHeight/0.5.2/jquery.matchHeight-min.js"></script> 
 <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.matchHeight/0.5.2/jquery.matchHeight-min.js"></script> <nav class="page-footer-nav row"> <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3"> <a href="">Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> </div> <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3"> <a href="">Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> </div> <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3"> <a href="">Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> </div> <div class="footer-nav-section col-xs-6 col-sm-4 col-md-3"> <a href="">Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> <a href="">Sub Menu Item</a> </div> </nav> 

Your problem is a content inside the footer-nav-section. 您的问题是页脚导航部分中的内容。 The problem is height of the div. 问题是div的高度。 You need to make all div's equal height. 您需要使所有div的高度相等。

Use matchheight.js 使用matchheight.js

and the function is, 函数是

  $('.page-footer-nav').each(function() {
$(this).children('.footer-nav-section').matchHeight();

}); });

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

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