What is the difference among col-lg-*, col-md-* and col-sm-* in Bootstrap?

前端 未结 11 1190
别跟我提以往
别跟我提以往 2020-11-22 14:39

What is the difference among col-lg-* , col-md-* and col-sm-* in Twitter Bootstrap?

相关标签:
11条回答
  • 2020-11-22 15:14

    One particular case : Before learning bootstrap grid system, make sure browser zoom is set to 100% (a hundred percent). For example : If screen resolution is (1600px x 900px) and browser zoom is 175%, then "bootstrap-ped" elements will be stacked.

    HTML

    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-4">class="col-lg-4"</div>
            <div class="col-lg-4">class="col-lg-4"</div>
        </div>
    </div>
    

    Chrome zoom 100%

    Browser 100 percent - elements placed horizontally

    Chrome zoom 175%

    Browser 175 percent - stacked elements

    0 讨论(0)
  • 2020-11-22 15:21

    well it's used to tell bootstrap how many columns are to be placed in a row depending on the screen size-

    col-xs-2
    

    would show only 2 columns in a row in extra small(xs) screen, in the same way as sm defines a small screen, md(medium sized), lg(large sized), but according to bootstrap smaller first rule, if you mention

    xs-col-2 md-col-4
    

    then 2 columns would be shown in every row for screen sizes from xs upto sm(included) and changes when it gets next size i.e. for md up to lg(included) for a better understanding of screen sizes try running them in various screen modes in chrome's developer mode(ctr+shift+i) and try various pixels or devices

    0 讨论(0)
  • 2020-11-22 15:24

    I think this image is pretty good to understand the concept better!

    for more detail understanding please go though below link:

    https://getbootstrap.com/docs/3.4/css/

    0 讨论(0)
  • 2020-11-22 15:25

    The bootstrap docs do explain it, but it still took me a while to get it. It makes more sense when I explain it to myself in one of two ways:

    If you think of the columns starting out horizontally, then you can choose when you want them to stack.

    For example, if you start with columns: A B C

    You decide when should they stack to be like this:

    A

    B

    C

    If you choose col-lg, then the columns will stack when the width is < 1200px.

    If you choose col-md, then the columns will stack when the width is < 992px.

    If you choose col-sm, then the columns will stack when the width is < 768px.

    If you choose col-xs, then the columns will never stack.

    On the other hand, if you think of the columns starting out stacked, then you can choose at what point they become horizontal:

    If you choose col-sm, then the columns will become horizontal when the width is >= 768px.

    If you choose col-md, then the columns will become horizontal when the width is >= 992px.

    If you choose col-lg, then the columns will become horizontal when the width is >= 1200px.

    0 讨论(0)
  • 2020-11-22 15:30

    Device Sizes and class prefix:

    • Extra small devices Phones (<768px) - .col-xs-
    • Small devices Tablets (≥768px) - .col-sm-
    • Medium devices Desktops (≥992px) - .col-md-
    • Large devices Desktops (≥1200px) - .col-lg-

    Grid options:

    Reference: Grid System

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