跳到主要内容

css

React Strict DOM 提供了一种内置的方式来创建和使用样式、变量和主题。

概述

样式在 JavaScript 中使用 CSS 功能的严格子集定义。定义和使用样式只需要组件内的本地知识。要了解有关每个 css 函数的更多信息,请参阅以下指南。

兼容性

下表代表了 React Strict DOM 的严格 CSS API 在跨平台 React 开发中的兼容性状态。 下面列出的所有 API 都被认为在 Web 上受支持。

✅ = React Native 内置支持
🟡 = 在 JavaScript 中进行了 Polyfill
❌ = 不支持

APIsAndroidiOSIssue #
css.create()🟡🟡
css.createTheme()🟡🟡
css.defineVars()🟡🟡
css.firstThatWorks()🟡🟡
状态AndroidiOSIssue #
:active🟡🟡
:focus🟡🟡
:hover🟡🟡
::placeholder🟡🟡
@media🟡🟡
AndroidiOSIssue #
% 单位
calc()
clamp()
em 单位🟡🟡
max()
min()
minmax()
inherit🟡 部分🟡 部分
px 单位🟡🟡
rem 单位🟡🟡
unset🟡 部分🟡 部分
url()
v* 单位🟡🟡
属性AndroidiOSIssue #
自定义属性🟡🟡
alignContent
alignItems
alignSelf
animationDelay#3
animationDirection#3
animationDuration#3
animationFillMode#3
animationIterationCount#3
animationName#3
animationPlayState#3
animationTimingFunction#3
aspectRatio (字符串)🟡🟡
backdropFilter
backfaceVisibility
backgroundColor
backgroundImage
backgroundOrigin
backgroundPosition
backgroundRepeat
backgroundSize
blockSize🟡🟡
borderBlockColor🟡🟡
borderBlockEndColor🟡🟡
borderBlockEndStyle🟡🟡
borderBlockEndWidth🟡🟡
borderBlockStartColor🟡🟡
borderBlockStartStyle🟡🟡
borderBlockStartWidth🟡🟡
borderBlockStyle🟡🟡
borderBlockWidth🟡🟡
borderBottomColor
borderBottomLeftRadius
borderBottomRightRadius
borderBottomStyle
borderBottomWidth
borderColor
borderEndEndRadius🟡🟡
borderEndStartRadius🟡🟡
borderInlineColor🟡🟡
borderInlineEndColor🟡🟡
borderInlineEndStyle🟡🟡
borderInlineEndWidth🟡🟡
borderInlineStartColor🟡🟡
borderInlineStartStyle🟡🟡
borderInlineStartWidth🟡🟡
borderInlineStyle🟡🟡
borderInlineWidth🟡🟡
borderLeftColor
borderLeftStyle
borderLeftWidth
borderRadius
borderRadius % 值
borderRightColor
borderRightStyle
borderRightWidth
borderStartEndRadius🟡🟡
borderStartStartRadius🟡🟡
borderStyle
borderTopColor
borderTopLeftRadius
borderTopRightRadius
borderTopStyle
borderTopWidth
borderWidth
bottom
boxDecorationBreak
boxShadow
boxSizing
caretColor🟡
clipPath
color
columnGap
cursor✅ 部分
direction
display: block🟡 部分🟡 部分#2
display: contents
display: flex
display: grid#1
display: inline#2
display: inline-block#2
display: inline-flex
display: inline-grid#1
display: list-item
display: none
filter
flex
flexBasis
flexDirection
flexGrow
flexShrink
flexWrap
fontFamily
fontSize
fontStyle
fontVariant
fontWeight🟡🟡
gap
height
inlineSize🟡🟡
inset🟡🟡
insetBlock🟡🟡
insetBlockEnd🟡🟡
insetBlockStart🟡🟡
insetInline🟡🟡
insetInlineEnd🟡🟡
insetInlineStart🟡🟡
isolation
justifyContent
justifyItems
justifySelf
left
letterSpacing
lineClamp🟡🟡#136
lineHeight (包括无单位)🟡🟡
listStyle
listStylePosition
listStyleType
margin
marginBlock🟡🟡
marginBlockEnd🟡🟡
marginBlockStart🟡🟡
marginBottom
marginInline🟡🟡
marginInlineEnd🟡🟡
marginInlineStart🟡🟡
marginLeft
marginRight
marginTop
maxBlockSize🟡🟡
maxHeight
maxInlineSize🟡🟡
maxWidth
minBlockSize🟡🟡
minHeight
minInlineSize🟡🟡
minWidth
mixBlendMode
objectFit🟡🟡
objectPosition
opacity
outlineColor
outlineOffset
outlineStyle
outlineWidth
overflow
overflowBlock
overflowInline
overflowWrap
overflowX
overflowY
padding
paddingBlock🟡🟡
paddingBlockEnd🟡🟡
paddingBlockStart🟡🟡
paddingBottom
paddingInline🟡🟡
paddingInlineEnd🟡🟡
paddingInlineStart🟡🟡
paddingLeft
pointerRight
pointerTop
placeContent🟡🟡
placeItems
placeSelf
pointerEvents
position: absolute
position: fixed
position: relative
position: static
position: sticky
right
rotate
rowGap
scale
scrollSnap*
textAlign
textDecorationColor
textDecorationLine
textDecorationStyle
textShadow🟡🟡
textTransform
top
touchAction
transform
transform: matrix
transform: matrix3d
transform: perspective
transform: rotate
transform: rotate3d
transform: rotateX
transform: rotateY
transform: rotateZ
transform: scale
transform: scale3d
transform: scaleX
transform: scaleY
transform: scaleZ
transform: skew
transform: skewX
transform: skewY
transform: translate
transform: translate3d
transform: translateX
transform: translateY
transform: translateZ
transform: skew
transform: skewX
transform: skewY
transformOrigin
transformStyle
transitionDelay🟡🟡
transitionDuration🟡🟡
transitionProperty🟡🟡
transitionTimingFunction🟡🟡
translate
userSelect🟡🟡
verticalAlign🟡
visibility🟡🟡
whiteSpace
width
wordBreak
zIndex#100