Skip to Content
文档

间距

用于控制元素内边距和外边距的 JSX 样式属性。

内边距

¥Padding

所有边

¥All sides

使用 padding 属性在元素的所有侧应用填充

¥Use the padding prop to apply padding on all sides of an element

// raw value
<Box padding="40px" />
<Box p="40px" /> // shorthand

// token value
<Box padding="4" />
<Box p="4" /> // shorthand
属性CSS 属性标记类别
p,paddingpaddingspacing

特定边

¥Specific side

使用 padding{Left,Right,Top,Bottom} 在元素的一侧应用内边距

¥Use the padding{Left,Right,Top,Bottom} to apply padding on one side of an element

<Box paddingLeft="3" />
<Box pl="3" /> // shorthand

<Box paddingTop="3" />
<Box pt="3" /> // shorthand

使用 padding{Start,End} 属性根据文本方向在元素的逻辑轴上应用内边距。

¥Use the padding{Start,End} props to apply padding on the logical axis of an element based on the text direction.

<div className={css({ paddingStart: '8' })} />
<div className={css({ ps: '8' })} /> // shorthand

<div className={css({ paddingEnd: '8' })} />
<div className={css({ pe: '8' })} /> // shorthand
属性CSS 属性标记类别
pl, paddingLeftpadding-leftspacing
pr, paddingRightpadding-rightspacing
pt, paddingToppadding-topspacing
pb, paddingBottompadding-bottomspacing
ps, paddingStartpadding-inline-startspacing
pe, paddingEndpadding-inline-endspacing

水平和垂直内边距

¥Horizontal and Vertical padding

使用 padding{X,Y} 属性在元素的水平和垂直轴上应用内边距。

¥Use the padding{X,Y} props to apply padding on the horizontal and vertical axis of an element

<Box paddingX="8" />
<Box px="8" /> // shorthand

<Box paddingY="8" />
<Box py="8" /> // shorthand
属性CSS 属性标记类别
p,paddingpaddingspacing
pl, paddingLeftpadding-leftspacing
pr, paddingRightpadding-rightspacing
pt, paddingToppadding-topspacing
pb, paddingBottompadding-bottomspacing
px, paddingXpadding-inlinespacing
py, paddingYpadding-blockspacing
ps, paddingStartpadding-inline-startspacing
pe, paddingEndpadding-inline-endspacing

边距

¥Margin

所有边

¥All sides

使用 margin 属性在元素的所有侧应用边距

¥Use the margin prop to apply margin on all sides of an element

<Box margin="5" />
<Box m="5" /> // shorthand
属性CSS 属性标记类别
m,marginmarginspacing

特定边

¥Specific side

使用 margin{Left,Right,Top,Bottom} 在元素的一侧应用外边距

¥Use the margin{Left,Right,Top,Bottom} to apply margin on one side of an element

<Box marginLeft="3" />
<Box ml="3" /> // shorthand

<Box marginTop="3" />
<Box mt="3" /> // shorthand

使用 margin{Start,End} 属性根据文本方向在元素的逻辑轴上应用边距。

¥Use the margin{Start,End} properties to apply margin on the logical axis of an element based on the text direction.

<Box marginStart="8" />
<Box ms="8" /> // shorthand

<Box marginEnd="8" />
<Box me="8" /> // shorthand
属性CSS 属性标记类别
ml, marginLeftmargin-leftspacing
mr, marginRightmargin-rightspacing
mt, marginTopmargin-topspacing
mb, marginBottommargin-bottomspacing
ms, marginStartmargin-inline-startspacing
me, marginEndmargin-inline-endspacing

水平和垂直边距

¥Horizontal and Vertical margin

使用 margin{X,Y} 属性在元素的水平和垂直轴上应用边距。

¥Use the margin{X,Y} properties to apply margin on the horizontal and vertical axis of an element

<Box marginX="8" />
<Box mx="8" /> // shorthand

<Box marginY="8" />
<Box my="8" /> // shorthand
属性CSS 属性标记类别
mx, marginXmargin-leftspacing
my, marginYmargin-topspacing

列间距

¥Spacing Between

使用 space{X,Y} 属性在元素之间应用间距。此方法使用 OWL 选择器 > * + *,并通过 margin* 属性应用元素之间的间距。

¥Use the space{X,Y} props to apply spacing between elements. This approach uses the owl selector > * + * to apply the spacing between the elements using margin* properties.

info

当需要负间距时,建议使用 space 属性而不是 gap 属性来实现间距。

¥It's recommended to use the space prop over the gap prop for spacing when you need negative spacing.

<Box display="flex" spaceX="8">
  <Box>Item 1</Box>
  <Box>Item 2</Box>
  <Box>Item 3</Box>
</Box>

<Box display="flex" spaceY="8">
  <Box>Item 1</Box>
  <Box>Item 2</Box>
  <Box>Item 3</Box>
</Box>
属性CSS 属性标记类别
spaceXmargin-inline-startspacing
spaceYmargin-block-startspacing

Previous

尺寸

Next

SVG