>_FoxiRef
>_/cheatsheet/tailwind
TailwindCSS

TailwindCSS 速查表

常用TailwindCSS实用类集合

#响应式断点

CSS说明
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)超超大屏幕及以上

#状态(变体)

CSS说明
hover::hover鼠标悬停时
focus::focus聚焦时
active::active点击/按下时
disabled::disabled禁用时
first::first-child第一个子元素
last::last-child最后一个子元素
odd::nth-child(odd)奇数子元素
even::nth-child(even)偶数子元素
group-hover:.group:hover &父组悬停时
dark:@media (prefers-color-scheme: dark)深色模式

#间距

CSS说明
p-{size}padding全部内边距
px-{size}padding-left/right水平内边距
py-{size}padding-top/bottom垂直内边距
pt/pr/pb/pl-{size}padding-top/right/bottom/left单方向内边距
m-{size}margin全部外边距
mx-{size}margin-left/right水平外边距
my-{size}margin-top/bottom垂直外边距
mt/mr/mb/ml-{size}margin-top/right/bottom/left单方向外边距
mx-automargin: 0 auto水平居中
gap-{size}gapFlex/Grid间隙
gap-x-{size}column-gap水平间隙
gap-y-{size}row-gap垂直间隙
space-x-{size}> * + * { margin-left }子元素水平间距
space-y-{size}> * + * { margin-top }子元素垂直间距

#尺寸

CSS说明
w-{size}width宽度
w-fullwidth: 100%全宽
w-screenwidth: 100vw屏幕宽度
w-autowidth: auto自动宽度
w-fitwidth: fit-content适应内容
min-w-0min-width: 0最小宽度0
min-w-fullmin-width: 100%最小宽度100%
max-w-{size}max-width最大宽度
max-w-screen-{bp}max-width: breakpoint断点最大宽度
h-{size}height高度
h-fullheight: 100%全高
h-screenheight: 100vh屏幕高度
min-h-screenmin-height: 100vh最小屏幕高度
max-h-{size}max-height最大高度
size-{size}width + height同时设置宽高

#显示

CSS说明
blockdisplay: block块级元素
inline-blockdisplay: inline-block行内块
inlinedisplay: inline行内元素
flexdisplay: flexFlex容器
inline-flexdisplay: inline-flex行内Flex
griddisplay: gridGrid容器
inline-griddisplay: inline-grid行内Grid
hiddendisplay: none隐藏
contentsdisplay: contents仅内容

#Flexbox

CSS说明
flex-rowflex-direction: row水平方向
flex-colflex-direction: column垂直方向
flex-row-reverseflex-direction: row-reverse水平反向
flex-col-reverseflex-direction: column-reverse垂直反向
flex-wrapflex-wrap: wrap允许换行
flex-nowrapflex-wrap: nowrap不换行
flex-1flex: 1 1 0%填充剩余空间
flex-autoflex: 1 1 auto自动大小
flex-noneflex: none固定大小
growflex-grow: 1允许增长
grow-0flex-grow: 0禁止增长
shrinkflex-shrink: 1允许收缩
shrink-0flex-shrink: 0禁止收缩

#对齐

CSS说明
justify-startjustify-content: flex-start主轴起点
justify-centerjustify-content: center主轴居中
justify-endjustify-content: flex-end主轴终点
justify-betweenjustify-content: space-between两端对齐
justify-aroundjustify-content: space-around均匀分布
justify-evenlyjustify-content: space-evenly均匀间隔
items-startalign-items: flex-start交叉轴起点
items-centeralign-items: center交叉轴居中
items-endalign-items: flex-end交叉轴终点
items-baselinealign-items: baseline基线对齐
items-stretchalign-items: stretch拉伸填充
self-autoalign-self: auto自身自动
self-startalign-self: flex-start自身起点
self-centeralign-self: center自身居中
self-endalign-self: flex-end自身终点

#Grid网格

CSS说明
grid-cols-{n}grid-template-columns: repeat(n, 1fr)n列
grid-rows-{n}grid-template-rows: repeat(n, 1fr)n行
col-span-{n}grid-column: span n跨n列
col-start-{n}grid-column-start: n从第n列开始
col-end-{n}grid-column-end: n在第n列结束
row-span-{n}grid-row: span n跨n行
row-start-{n}grid-row-start: n从第n行开始
row-end-{n}grid-row-end: n在第n行结束
auto-cols-autogrid-auto-columns: auto自动列宽
auto-cols-frgrid-auto-columns: 1fr自动列1fr
auto-rows-autogrid-auto-rows: auto自动行高

#定位

CSS说明
staticposition: static静态定位
relativeposition: relative相对定位
absoluteposition: absolute绝对定位
fixedposition: fixed固定定位
stickyposition: sticky粘性定位
top-{size}top顶部偏移
right-{size}right右侧偏移
bottom-{size}bottom底部偏移
left-{size}left左侧偏移
inset-{size}top/right/bottom/left全方向偏移
inset-x-{size}left/right水平偏移
inset-y-{size}top/bottom垂直偏移
z-{n}z-indexZ轴顺序
z-autoz-index: autoZ轴自动

#排版

CSS说明
font-sansfont-family: sans-serif无衬线字体
font-seriffont-family: serif衬线字体
font-monofont-family: monospace等宽字体
text-xsfont-size: 0.75rem超小文字
text-smfont-size: 0.875rem小文字
text-basefont-size: 1rem基础文字
text-lgfont-size: 1.125rem大文字
text-xlfont-size: 1.25rem超大文字
text-2xl ~ 9xlfont-size: 1.5rem ~ 8rem更大文字尺寸
font-thinfont-weight: 100最细字重
font-lightfont-weight: 300细字重
font-normalfont-weight: 400正常字重
font-mediumfont-weight: 500中等字重
font-semiboldfont-weight: 600半粗体
font-boldfont-weight: 700粗体
italicfont-style: italic斜体
not-italicfont-style: normal非斜体
leading-{size}line-height行高
tracking-{size}letter-spacing字间距

#文本对齐与装饰

CSS说明
text-lefttext-align: left左对齐
text-centertext-align: center居中对齐
text-righttext-align: right右对齐
text-justifytext-align: justify两端对齐
underlinetext-decoration: underline下划线
line-throughtext-decoration: line-through删除线
no-underlinetext-decoration: none无装饰
uppercasetext-transform: uppercase大写
lowercasetext-transform: lowercase小写
capitalizetext-transform: capitalize首字母大写
truncateoverflow: hidden; text-overflow: ellipsis省略号截断
line-clamp-{n}-webkit-line-clamp: n限制n行
whitespace-nowrapwhite-space: nowrap不换行
break-wordsword-wrap: break-word断词换行

#颜色

CSS说明
text-{color}-{shade}color文字颜色
bg-{color}-{shade}background-color背景颜色
bg-gradient-to-{dir}background-image: linear-gradient渐变方向
from-{color}from color渐变起始色
via-{color}via color渐变中间色
to-{color}to color渐变结束色
text-transparentcolor: transparent透明文字
bg-transparentbackground-color: transparent透明背景
text-currentcolor: currentColor继承当前颜色

#边框

CSS说明
borderborder-width: 1px1px边框
border-{n}border-width: npxn像素边框
border-t/r/b/l-{n}border-top/right/bottom/left-width单方向边框
border-{color}border-color边框颜色
border-solidborder-style: solid实线
border-dashedborder-style: dashed虚线
border-dottedborder-style: dotted点线
border-noneborder-style: none无边框
roundedborder-radius: 0.25rem微圆角
rounded-mdborder-radius: 0.375rem中等圆角
rounded-lgborder-radius: 0.5rem大圆角
rounded-xlborder-radius: 0.75rem超大圆角
rounded-fullborder-radius: 9999px完全圆形
rounded-noneborder-radius: 0无圆角
rounded-t/r/b/l-{size}border-radius (corners)特定圆角

#效果

CSS说明
shadow-smbox-shadow: small小阴影
shadowbox-shadow: default默认阴影
shadow-mdbox-shadow: medium中等阴影
shadow-lgbox-shadow: large大阴影
shadow-xlbox-shadow: extra large超大阴影
shadow-2xlbox-shadow: 2x large最大阴影
shadow-innerbox-shadow: inset内阴影
shadow-nonebox-shadow: none无阴影
opacity-{n}opacity: n%透明度(0-100)
blurfilter: blur(8px)模糊
blur-{size}filter: blur(size)模糊程度
brightness-{n}filter: brightness(n%)亮度
contrast-{n}filter: contrast(n%)对比度
grayscalefilter: grayscale(100%)灰度
invertfilter: invert(100%)反转

#过渡与动画

CSS说明
transitiontransition-property: all默认过渡
transition-alltransition-property: all全部属性过渡
transition-colorstransition-property: colors颜色过渡
transition-opacitytransition-property: opacity透明度过渡
transition-transformtransition-property: transform变换过渡
duration-{ms}transition-duration: ms持续时间
ease-lineartransition-timing: linear线性缓动
ease-intransition-timing: ease-in缓入
ease-outtransition-timing: ease-out缓出
ease-in-outtransition-timing: ease-in-out缓入缓出
delay-{ms}transition-delay: ms延迟
animate-spinanimation: spin旋转动画
animate-pinganimation: ping脉冲动画
animate-pulseanimation: pulse呼吸动画
animate-bounceanimation: bounce弹跳动画

#变换

CSS说明
scale-{n}transform: scale(n)缩放
scale-x-{n}transform: scaleX(n)水平缩放
scale-y-{n}transform: scaleY(n)垂直缩放
rotate-{deg}transform: rotate(deg)旋转
translate-x-{size}transform: translateX水平移动
translate-y-{size}transform: translateY垂直移动
skew-x-{deg}transform: skewX(deg)水平倾斜
skew-y-{deg}transform: skewY(deg)垂直倾斜
origin-centertransform-origin: center变换原点居中
origin-toptransform-origin: top变换原点顶部
origin-bottomtransform-origin: bottom变换原点底部

#溢出与其他

CSS说明
overflow-autooverflow: auto必要时滚动
overflow-hiddenoverflow: hidden隐藏溢出
overflow-scrolloverflow: scroll始终滚动
overflow-visibleoverflow: visible显示溢出
overflow-x-{value}overflow-x水平溢出
overflow-y-{value}overflow-y垂直溢出
cursor-pointercursor: pointer指针光标
cursor-not-allowedcursor: not-allowed禁止光标
pointer-events-nonepointer-events: none禁用指针事件
select-noneuser-select: none禁止选择
select-textuser-select: text允许文本选择
select-alluser-select: all点击全选
sr-onlyscreen reader only仅屏幕阅读器

#颜色调色板

slate
gray
zinc
red
orange
amber
yellow
lime
green
emerald
teal
cyan
sky
blue
indigo
violet
purple
fuchsia
pink
rose

💡 Click a color block to copy the class name (e.g., blue-500)

Usage: text-{color}-{shade}, bg-{color}-{shade}, border-{color}-{shade}

#尺寸比例参考

00pxpx1px
0.50.125rem (2px)10.25rem (4px)
20.5rem (8px)30.75rem (12px)
41rem (16px)51.25rem (20px)
61.5rem (24px)82rem (32px)
102.5rem (40px)123rem (48px)
164rem (64px)205rem (80px)
246rem (96px)328rem (128px)

#常见问题 (FAQ)

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

TailwindCSS 速查表 - 类参考 | Foxi Dev Reference