col-*-12 (col-xs / col-sm / etc) use in Bootstrap 3

前端 未结 2 604
面向向阳花
面向向阳花 2020-12-09 04:27

I see something like the following in code examples on StackOverflow and in themes for sale even (never in Bootstrap\'s examples).

2条回答
  •  醉梦人生
    2020-12-09 05:14

    Your frustration is right..

    is totally redundant.

    Because Bootstrap 3+ is mobile first, any col-classes you declare travel up, meaning they apply to the declared device (xs, sm, md, lg) and larger. So, col-xs-12 col-sm-12 is redundant. Just use col-xs-12 for the same effect.

    Also, if you don't declare an xs class, the layout will default to col-*-12 once below the smalles col-class you do declare. e.g.

    is half-width on sm and up, but full-width on xs. Whereas
    is half width on md and up, but full width on sm and xs.

    This being said, you should always declare at least one col-class, so it gets the relevant padding and other styling specifics.

提交回复
热议问题