Margin & Padding - 图1

Work in progress!

More detailed documentation is coming soon, but in the meantime here’s a quick class reference.

Control an element’s padding and margin using the .p{side?}-{size}, .m{side?}-{size}, and .-m{side?}-{size} utilities.

For example, .pt-2 would add .5rem of padding to the top of the element, .mx-0 would make the horizontal margin zero, and .-mb-6 would add a 1.5rem negative margin to the bottom of an element.

Class

Margin & Padding - 图2

Padding

Margin & Padding - 图3

Margin

Margin & Padding - 图4

Negative Margin

Side (optional)

Margin & Padding - 图5

All (default)

Margin & Padding - 图6

Top

Margin & Padding - 图7

Right

Margin & Padding - 图8

Bottom

Margin & Padding - 图9

Left

Margin & Padding - 图10

Horizontal

Margin & Padding - 图11

Vertical

Space

Margin & Padding - 图12

0

Margin & Padding - 图13

0.25rem

Margin & Padding - 图14

0.5rem

Margin & Padding - 图15

0.75rem

Margin & Padding - 图16

1rem

Margin & Padding - 图17

1.25rem

Margin & Padding - 图18

1.5rem

Margin & Padding - 图19

2rem

Margin & Padding - 图20

2.5rem

Margin & Padding - 图21

3rem

Margin & Padding - 图22

4rem

Margin & Padding - 图23

5rem

Margin & Padding - 图24

6rem

Margin & Padding - 图25

8rem

Margin & Padding - 图26

1px

Margin & Padding - 图27

auto (margins only)

Customizing

Responsive and State Variants

By default, only responsive variants are generated for margin, negative margin and padding utilities.

You can control which variants are generated for the list utilities by modifying the margin, negativeMargin and padding property in the modules section of your Tailwind config file.

For example, this config will also generate hover and focus variants of the margin utilities, hover variants of the negative margin utilities, and focus variants of the padding utilities:

  1. {
  2. // ...
  3. modules: {
  4. // ...
  5. margin: ['responsive', 'hover', 'focus'],
  6. negativeMargin: ['responsive', 'hover'],
  7. padding: ['responsive', 'focus'],
  8. }
  9. }

Disabling

If you aren’t using the margin, the negative margin, or padding utilities in your project, you can disable them entirely by setting the margin, negativeMargin and padding property to false in the modules section of your config file:

  1. {
  2. // ...
  3. modules: {
  4. // ...
  5. margin: false,
  6. negativeMargin: false,
  7. padding: false,
  8. }
  9. }