How do I use the Spacing Utility Classes on Bootstrap 4

前端 未结 3 1336
抹茶落季
抹茶落季 2020-11-27 18:20

In this article I saw Bootstrap 4 Spacing Utility Classes, and he uses m-b-lg in className.

相关标签:
3条回答
  • 2020-11-27 18:56

    Basically its only works from 0 to 3. m-t-0, m-t-1, m-t-2, or m-t-3

    0 讨论(0)
  • 2020-11-27 19:14

    Update 2020 Bootstrap 4

    The Bootstrap 4 spacing utils have changed since the original answer (for v4 alpha). Now the syntax is simply:

    • margins: m{sides}-{size}
    • padding: p{sides}-{size}

    Examples..

    mb-2 = margin bottom 2 spacing units
    m-0 = no margins
    pt-3 = padding top 3 spacing units
    p-1 = padding all sides 1 spacing unit

    There are now 6 sizes (0-5) that represent a portion of the standard .5rem spacer unit. Additionally, x-axis (left/right) and y-axis (top/bottom) utils have been added:

    my-2 = margin top & bottom 2 spacing units
    mx-0 = no margins left & right
    px-3 = padding left & right 3 spacing units

    And, the spacing utils are now responsive. The smallest xs breakpoint is implied when no breakpoint is used.

    • margins: m{sides}-{breakpoint}-{size}
    • padding: p{sides}-{breakpoint}-{size}

    mt-md-2 = margin top 2 spacing units, on md (and up)
    py-sm-0 = no padding top & bottom, on sm (and up)

    Bootstrap 4 Spacing Utils Demo


    Related: Bootstrap 4 spacing bug?

    0 讨论(0)
  • 2020-11-27 19:18

    Refer to the Spacing (Bootstrap v4 alpha) documentation.

    The classes are named using the format: {property}-{sides}-{size}

    Where size is one of: * 0 - for classes that eliminate the margin or padding by setting it to 0 * 1 - (by default) for classes that set the margin or padding to $spacer-xor $spacer-y * 2 - (by default) for classes that set the margin or padding to $spacer-x * 1.5 or $spacer-y * 1.5 * 3 - (by default) for classes that set the margin or padding to $spacer-x * 3 or $spacer-y * 3.

    So use m-t-3 instead of m-t-lg.

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