Change number of columns depending on screen size

后端 未结 3 746
既然无缘
既然无缘 2021-01-13 04:07

I am experimenting with Bootstrap and I was wondering how can I adjust number of columns depending of screen size. I saw this from Bootstrap CSS tutorial:

&l         


        
相关标签:
3条回答
  • 2021-01-13 04:39
    <div class="row">
    <div class="col-lg-6 visible-lg">Column 6 Large</div>
    <div class="col-md-3 visible-md">Column 1 Medium</div>
    <div class="col-md-3 visible-md">Column 2 Medium</div>
    <div class="col-xs-2 visible-xs">Column 1 Small</div>
    <div class="col-xs-2 visible-xs">Column 2 Small</div>
    <div class="col-xs-2 visible-xs">Column 3 Small</div>
    </row>
    

    It should be noted that having duplicate content in separate columns like this isn't great for SEO. You might want to instead approach this by using nested columns for more granular control over your content without having to duplicate it.

    0 讨论(0)
  • 2021-01-13 05:01
    <div class="row">
        <div class="col-lg-2 col-md-4 col-xs-6"></div>
        <div class="col-lg-2 col-md-4 col-xs-6"></div>
        <div class="col-lg-2 col-md-4 hidden-sm hidden-xs"></div>
        <div class="col-lg-2 hidden-md hidden-sm hidden-xs"></div>
        <div class="col-lg-2 hidden-md hidden-sm hidden-xs"></div>
        <div class="col-lg-2 hidden-md hidden-sm hidden-xs"></div>
    </div>
    <div class="row">
        <div class="hidden-lg col-md-4 col-xs-4"></div>
        <div class="hidden-lg col-md-4 col-xs-4"></div>
        <div class="hidden-lg col-md-4 hidden-sm hidden-xs"></div>
    </div>
    <div class="row">
        <div class="hidden-lg hidden-md col-xs-4"></div>
        <div class="hidden-lg hidden-md col-xs-4"></div>
    </div>
    
    0 讨论(0)
  • Yes, you can change number of columns with Bootstrap. That's what flexible grid is for.

    Here's an example that follows your instructions:

    <div class="row">
      <div class="col-xs-6 col-md-4 col-lg-2">first</div>
      <div class="col-xs-6 col-md-4 col-lg-2">second</div>
    
      <div class="col-xs-6 col-md-4 col-lg-2">third</div>
      <div class="col-xs-6 col-md-4 col-lg-2">fourth</div>
    
      <div class="col-xs-6 col-md-4 col-lg-2">fifth</div>
      <div class="col-xs-6 col-md-4 col-lg-2">sixth</div>
    </div>
    

    See Bootply Demo.

    0 讨论(0)
提交回复
热议问题