How to use bootstrap with 16 or 24 columns

后端 未结 10 632
轮回少年
轮回少年 2020-11-29 03:39

I need some help setting bootstrap 2.0.4 to be 16 or 24 column instead of the default 12 columns i can\'t understand what am i doing wrong i tried the customize option on th

相关标签:
10条回答
  • 2020-11-29 04:15

    Updated 2018

    Revisiting this question for the latest Bootstrap 4. Now that Bootstrap 4 is flexbox, and includes auto-layout columns, it's easy to create layouts with any number of n columns...

    16 columns

    <div class="row">
                <div class="col">
                    1
                </div>
                <div class="col">
                    2
                </div>
                <div class="col">
                    ... to 16
                </div>
    </div>
    

    24 columns

    <div class="row">
                <div class="col">
                    1
                </div>
                <div class="col">
                    2
                </div>
                <div class="col">
                    ... to 24
                </div>
    </div>
    

    Demo: https://www.codeply.com/go/4sQGt2qKyr


    Also see: N number of columns in Bootstrap 4

    0 讨论(0)
  • 2020-11-29 04:17

    This method is for an older version of Bootstrap - Version 2.3.1

    Click this link to customize bootstrap: http://twitter.github.com/bootstrap/customize.html

    You will find examples such as this. Change the parameters to fit your needs.

    16 Grid system with Gutter
    @gridColumns: 16
    @gridColumnWidth: 45px
    @gridGutterWidth: 15px
    @gridColumnWidth1200: 52.5px
    @gridGutterWidth1200: 22.5px
    @gridColumnWidth768: 31.5px
    @gridGutterWidth768: 15px
    
    16 Grid system without Gutter
    @gridColumns: 16
    @gridColumnWidth: 60px
    @gridGutterWidth: 0px
    @gridColumnWidth1200: 75px
    @gridGutterWidth1200: 0px
    @gridColumnWidth768: 46.5px
    @gridGutterWidth768: 0px
    

    24 Grid system with Gutter
    @gridColumns: 24
    @gridColumnWidth: 30px
    @gridGutterWidth: 1px
    @gridColumnWidth1200: 35px
    @gridGutterWidth1200: 15px
    @gridColumnWidth768: 21px
    @gridGutterWidth768: 10px
    
    24 Grid system without Gutter
    @gridColumns: 24
    @gridColumnWidth: 40px
    @gridGutterWidth: 0px
    @gridColumnWidth1200: 50px
    @gridGutterWidth1200: 0px
    @gridColumnWidth768: 31px
    @gridGutterWidth768: 0px
    
    0 讨论(0)
  • 2020-11-29 04:18

    You can override the width attribute with percentage like this:

        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
        <div class="col-md-1" style="width: 6.25%">nothing</div>
    

    It will even maintain the responsive capabilities.

    0 讨论(0)
  • 2020-11-29 04:20

    Here is a quick and easy way I found to do 16 columns using nesting...

    .no-padding {
      padding-left: 0 !important;
      padding-right: 0 !important;
    }
    <div class="row">
      <div class="col-md-3 no-padding">
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
      </div>
      <div class="col-md-3 no-padding">
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
      </div>
      <div class="col-md-3 no-padding">
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
      </div>
      <div class="col-md-3 no-padding">
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
        <div class="col-md-3">
          col
        </div>
      </div>
    </div>
    <!-- row -->

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