Skip to main content

Tailwind CSS Reference

Spacing

screenmin widthcontainerrem
100%
sm640px640px40rem
md768px768px48rem
lg1024px1024px64rem
xl1280px1280px80rem
2xl1536px1536px96rem
  • container - 实际为定义 max-w
  • max-{PREFIX} 可以限定固定范围
    • md:max-md:underline - 限定在 md 范围内
spacingsizepx
00px0px
px1px1px
0.50.125rem2px
10.25rem4px
41rem16px
<n>n×0.25remn×4px
  • 0-4 - 0.5 递增
  • 4-12 - 1 递增
  • 12,14,16
  • 20-96 - 4 递增
  • spacing 用于 padding, margin, width, height, maxHeight, gap, inset, space, translate
  • Default spacing scale
roundedrempx
xrounded-none00
rounded-sm0.1252
rounded0.254
rounded-md0.3756
rounded-lg0.58
rounded-xl0.7512
rounded-2xl116
rounded-3xl1.524
rounded-full9999

Width

max-widthrempxnote
max-w-xs20rem320pxscreen 的一半
max-w-sm24rem384px
max-w-md28rem448px
max-w-lg32rem512px
max-w-xl36rem576px
max-w-2xl42rem672px
max-w-prose65ch
max-w-screen-sm640px
max-w-screen-md768px
max-w-screen-lg1024px
max-w-screen-xl1280px
max-w-screen-2xl1536px

Font

textrempxdiff
text-xs0.75 rem12 px-2 px
text-sm0.875 rem14 px-2 px
text-base1 rem16 px0
text-lg1.125 rem18 px+2 px
text-xl1.25 rem20 px+2 px
text-2xl1.5 rem24 px+6 px
text-3xl1.875 rem30 px+6 px
text-4xl2.25 rem36 px+6 px
text-5xl3 rem48 px+12 px
text-6xl3.75 rem60 px+12 px
text-7xl4.5 rem72 px+12 px
text-8xl6 rem96 px+24 px
text-9xl8 rem128 px+32 px
fontweight
font-thin100
font-extralight200
font-light300
font-normal400
font-medium500
font-semibold600
font-bold700
font-extrabold800
font-black900

Container Query

NameCSSdiffw
@xs@container (min-width: 20rem /* 320px */)w-80
@sm@container (min-width: 24rem /* 384px */)+4remw-96
@md@container (min-width: 28rem /* 448px */)+4rem
@lg@container (min-width: 32rem /* 512px */)+4rem
@xl@container (min-width: 36rem /* 576px */)+4rem
@2xl@container (min-width: 42rem /* 672px */)+6rem
@3xl@container (min-width: 48rem /* 768px */)+6rem
@4xl@container (min-width: 56rem /* 896px */)+8rem
@5xl@container (min-width: 64rem /* 1024px */)+8rem
@6xl@container (min-width: 72rem /* 1152px */)+8rem
@7xl@container (min-width: 80rem /* 1280px */)+8rem
  • xs,sm,md,lg,xl - 4rem/step - 64px/step
  • xl -> 7xl - 8rem/step - 128px/step

Modifier

ModifierCSS
hover&:hover
focus&:focus
focus-within&:focus-within
focus-visible&:focus-visible
active&:active
visited&:visited
target&:target
*& > *
has&:has
first&:first-child
last&:last-child
only&:only-child
odd&:nth-child(odd)
even&:nth-child(even)
first-of-type&:first-of-type
last-of-type&:last-of-type
only-of-type&:only-of-type
empty&:empty
disabled&:disabled
enabled&:enabled
checked&:checked
indeterminate&:indeterminate
default&:default
required&:required
valid&:valid
invalid&:invalid
in-range&:in-range
out-of-range&:out-of-range
placeholder-shown&:placeholder-shown
autofill&:autofill
read-only&:read-only
before&::before
after&::after
first-letter&::first-letter
first-line&::first-line
marker&::marker
selection&::selection
file&::file-selector-button
backdrop&::backdrop
placeholder&::placeholder
sm@media (min-width: 640px)
md@media (min-width: 768px)
lg@media (min-width: 1024px)
xl@media (min-width: 1280px)
2xl@media (min-width: 1536px)
min-[…]@media (min-width: …)
max-sm@media not all and (min-width: 640px)
max-md@media not all and (min-width: 768px)
max-lg@media not all and (min-width: 1024px)
max-xl@media not all and (min-width: 1280px)
max-2xl@media not all and (min-width: 1536px)
max-[…]@media (max-width: …)
dark@media (prefers-color-scheme: dark)
portrait@media (orientation: portrait)
landscape@media (orientation: landscape)
motion-safe@media (prefers-reduced-motion: no-preference)
motion-reduce@media (prefers-reduced-motion: reduce)
contrast-more@media (prefers-contrast: more)
contrast-less@media (prefers-contrast: less)
print@media print
supports-[…]@supports (…)
aria-checked&[aria-checked=“true”]
aria-disabled&[aria-disabled=“true”]
aria-expanded&[aria-expanded=“true”]
aria-hidden&[aria-hidden=“true”]
aria-pressed&[aria-pressed=“true”]
aria-readonly&[aria-readonly=“true”]
aria-required&[aria-required=“true”]
aria-selected&[aria-selected=“true”]
aria-[…]&[aria-…]
data-[…]&[data-…]
rtl[dir=“rtl”] &
ltr[dir=“ltr”] &
open&[open]