Skip to content
目录

通用布局样式

所有视图组件都支持以下通用布局样式规则,包括 Flexbox 样式、盒模型样式。

Flexbox 样式

属性名类型默认值说明示例
positionstring'relative'布局方式,分相对布局和绝对布局,相对布局即flex布局position: 'relative' | 'absolute' | 'fixed'
flexDirectionstring'column'主轴方向flexDirection:'column' | 'row'
flexWrapstring'nowrap'子控件是否折行排列flexWrap: 'nowrap' | 'wrap' | 'wrap-reverse'
justifyContentstring'flex-start'主轴方向上的子控件排列方式justifyContent: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly'
alignItemsstring'stretch'交叉轴方向上的子控件的对齐方式alignItems: 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch'
alignContentstring'flex-start'多主轴情况下,交叉轴方向上的子控件的排列方式alignContent: flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'stretch'
flexGrownumber0子控件占有父容器剩余空间的权重flexGrow: 1
flexShrinknumber0父容器空间不足时,子控件的收缩权重flexShrink: 1
flexBasisnumber|string'auto'子控件在进行拉伸和收缩计算前的基础尺寸flexBasis: 500 | 'auto'
alignSelfstring'auto'子控件在交叉轴上的对齐方式alignSelf: 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch'

盒模型样式

属性名类型默认值说明示例
widthnumber|string'auto'宽度width: 10 | '10px'
heightnumber|string'auto'高度height: 10 | '10px'
minWidthnumber|string0最小宽度minWidth: 10 | '10px'
minHeightnumber|string0最小高度minHeight: 10 | '10px'
maxWidthnumber|string最大宽度maxWidth: 10 | '10px'
maxHeightnumber|string最大高度maxHeight: 10 | '10px'
margin/marginAllnumber|string0所有四个边的外边距margin: 10 | '10px'
marginLeftnumber|string0左外边距marginLeft: 10 | '10px'
marginTopnumber|string0上外边距marginTop: 10 | '10px'
marginRightnumber|string0右外边距marginRight: 10 | '10px'
marginBottomnumber|string0下外边距marginBottom: 10 | '10px'
padding/paddingAllnumber|string0所有四个边的内边距padding: 10 | '10px'
paddingLeftnumber|string0左内边距paddingLeft: 10 | '10px'
paddingTopnumber|string0上内边距paddingTop: 10 | '10px'
paddingRightnumber|string0右内边距paddingRight: 10 | '10px'
paddingBottomnumber|string0下内边距paddingBottom: 10 | '10px'
leftnumber|string0距离左边的偏移量left: 10 | '10px'
topnumber|string0距离上方的偏移量top: 10 | '10px'
rightnumber|string0距离右边的偏移量right: 10 | '10px'
bottomnumber|string0距离下方的偏移量bottom: 10 | '10px'
displaystring'flex'控件是否显示('none'为不显示,且不参与布局)display: 'none' | 'flex'

所有 长度单位 请参考:长度单位