What are the difference between col-lg and col-md in bootstrap3

后端 未结 3 493
别跟我提以往
别跟我提以往 2020-12-05 14:08

What are the difference between col-lg, col-md ,col-xs and col-sm grid system in in bootstrap 3.

In a bo

3条回答
  •  天命终不由人
    2020-12-05 14:33

    When using Bootstrap those are the classes which are added for one column grid and correspond to extra small, small, medium and large devices.

    .col-xs = *Extra small devices (ie Phones) (<768px)

    .col-sm = Small devices (ie Tablets) (≥768px)

    .col-md = Medium devices (ie laptops, or small desktops) (≥992px)

    .col-lg = Large devices (ie Desktops) (≥1200px)*

    This way through media queries you can allow to have only the right classes interpreted by the browser. If you surf that website from a tablet for example, you will see that the css properties which are actually applied in the browser are only the ones for the .col-sm class.

    UPDATE

    Also it's important to mention that those classes are used on a grid of 12 columns in total which is the grid system setup used by Bootstrap.

    Therefore when you are using .col-sm-4 on an element it means that the element will take 4 columns out of 12 of the total width. Which logically means that if .col-sm-4 is used then only 3 elements per row can fit into the page on tablet.

    For example, let's say we want to show some project cards for a portfolio:

    Project 1
    HTML5, CSS, JS

    Using class="col-xs-12 col-sm-6 col-md-4 col-lg-3" all at the same time is used to activate different CSS properties on an element when viewing the page on a particular device.

    In other terms, if the user opens the site on a desktop, col-lg-3 means that a total of 4 cards will be displayed, when col-md-4 means a total of 3 cards, col-sm-6 a total of 2 cards and then col-xs-12 means on mobile only 1 card will with 100% width of the page.

提交回复
热议问题