tailwindcss

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Tailwind CSS

Tailwind CSS

The skill is based on Tailwind CSS v4.1.18, generated at 2026-01-28.
Tailwind CSS is a utility-first CSS framework for rapidly building custom user interfaces. Instead of writing custom CSS, you compose designs using utility classes directly in your markup. Tailwind v4 introduces CSS-first configuration with theme variables, making it easier to customize your design system.
本技能基于Tailwind CSS v4.1.18,生成于2026年1月28日。
Tailwind CSS是一个实用优先的CSS框架,用于快速构建自定义用户界面。无需编写自定义CSS,你可以直接在标记语言中组合工具类来完成设计。Tailwind v4引入了基于CSS的主题变量配置,让自定义设计系统变得更加容易。

Core References

核心参考

TopicDescriptionReference
InstallationVite, PostCSS, CLI, and CDN setupcore-installation
Utility ClassesUnderstanding Tailwind's utility-first approach and styling elementscore-utility-classes
Theme VariablesDesign tokens, customizing theme, and theme variable namespacescore-theme
Responsive DesignMobile-first breakpoints, responsive variants, and container queriescore-responsive
VariantsApplying utilities conditionally with state, pseudo-class, and media query variantscore-variants
PreflightTailwind's base styles and how to extend or disable themcore-preflight
主题描述参考
安装Vite、PostCSS、CLI和CDN配置core-installation
工具类理解Tailwind的实用优先方法及元素样式设置core-utility-classes
主题变量设计令牌、自定义主题及主题变量命名空间core-theme
响应式设计移动优先断点、响应式变体及容器查询core-responsive
变体通过状态、伪类和媒体查询变体条件性应用工具类core-variants
基础样式Tailwind的基础样式及其扩展或禁用方式core-preflight

Layout

布局

Display & Flexbox & Grid

显示与Flexbox与Grid

TopicDescriptionReference
Displayflex, grid, block, inline, hidden, sr-only, flow-root, contentslayout-display
Flexboxflex-direction, justify, items, gap, grow, shrink, wrap, orderlayout-flexbox
Gridgrid-cols, grid-rows, gap, place-items, col-span, row-span, subgridlayout-grid
Aspect RatioControlling element aspect ratio for responsive medialayout-aspect-ratio
ColumnsMulti-column layout for magazine-style or masonry layoutslayout-columns
主题描述参考
显示flex、grid、block、inline、hidden、sr-only、flow-root、contentslayout-display
Flexboxflex-direction、justify、items、gap、grow、shrink、wrap、orderlayout-flexbox
Gridgrid-cols、grid-rows、gap、place-items、col-span、row-span、subgridlayout-grid
宽高比控制元素宽高比以适配响应式媒体layout-aspect-ratio
多列布局用于杂志风格或瀑布流布局的多列布局layout-columns

Positioning

定位

TopicDescriptionReference
PositionControlling element positioning with static, relative, absolute, fixed, and stickylayout-position
InsetControlling placement of positioned elements with top, right, bottom, left, and inset utilitieslayout-inset
主题描述参考
定位使用static、relative、absolute、fixed和sticky控制元素定位layout-position
内边距偏移使用top、right、bottom、left和inset工具类控制定位元素的位置layout-inset

Sizing

尺寸

TopicDescriptionReference
WidthSetting element width with spacing scale, fractions, container sizes, and viewport unitslayout-width
HeightSetting element height with spacing scale, fractions, viewport units, and content-based sizinglayout-height
Min & Max Sizingmin-width, max-width, min-height, max-height constraintslayout-min-max-sizing
主题描述参考
宽度使用间距比例、分数、容器尺寸和视口单位设置元素宽度layout-width
高度使用间距比例、分数、视口单位和基于内容的尺寸设置元素高度layout-height
最小与最大尺寸min-width、max-width、min-height、max-height约束layout-min-max-sizing

Spacing

间距

TopicDescriptionReference
MarginControlling element margins with spacing scale, negative values, logical properties, and space utilitieslayout-margin
PaddingControlling element padding with spacing scale, logical properties, and directional utilitieslayout-padding
主题描述参考
外边距使用间距比例、负值、逻辑属性和间距工具类控制元素外边距layout-margin
内边距使用间距比例、逻辑属性和方向工具类控制元素内边距layout-padding

Overflow

溢出

TopicDescriptionReference
OverflowControlling how elements handle content that overflows their containerlayout-overflow
主题描述参考
溢出控制元素处理超出容器内容的方式layout-overflow

Images & Replaced Elements

图片与替换元素

TopicDescriptionReference
Object Fit & PositionControlling how images and video are resized and positionedlayout-object-fit-position
主题描述参考
对象适配与定位控制图片和视频的缩放与定位方式layout-object-fit-position

Tables

表格

TopicDescriptionReference
Table Layoutborder-collapse, table-auto, table-fixedlayout-tables
主题描述参考
表格布局border-collapse、table-auto、table-fixedlayout-tables

Transforms

变换

TopicDescriptionReference
Transform BaseBase transform utilities for enabling transforms, hardware acceleration, and custom transform valuestransform-base
TranslateTranslating elements on x, y, and z axes with spacing scale, percentages, and custom valuestransform-translate
RotateRotating elements in 2D and 3D space with degree values and custom rotationstransform-rotate
ScaleScaling elements uniformly or on specific axes with percentage valuestransform-scale
SkewSkewing elements on x and y axes with degree valuestransform-skew
主题描述参考
变换基础启用变换、硬件加速和自定义变换值的基础变换工具类transform-base
平移使用间距比例、百分比和自定义值在x、y、z轴上平移元素transform-translate
旋转使用角度值和自定义旋转在2D和3D空间中旋转元素transform-rotate
缩放使用百分比值均匀或按特定轴缩放元素transform-scale
倾斜使用角度值在x和y轴上倾斜元素transform-skew

Typography

排版

TopicDescriptionReference
Font & TextFont size, weight, color, line-height, letter-spacing, decoration, truncatetypography-font-text
Text AlignControlling text alignment with left, center, right, justify, and logical propertiestypography-text-align
List Stylelist-style-type, list-style-position for bullets and markerstypography-list-style
主题描述参考
字体与文本字体大小、字重、颜色、行高、字母间距、装饰、截断typography-font-text
文本对齐使用left、center、right、justify和逻辑属性控制文本对齐typography-text-align
列表样式用于项目符号和标记的list-style-type、list-style-positiontypography-list-style

Visual

视觉效果

TopicDescriptionReference
BackgroundBackground color, gradient, image, size, positionvisual-background
BorderBorder width, color, radius, divide, ringvisual-border
EffectsBox shadow, opacity, mix-blend, backdrop-blur, filtervisual-effects
SVGfill, stroke, stroke-width for SVG and icon stylingvisual-svg
主题描述参考
背景背景颜色、渐变、图片、尺寸、位置visual-background
边框边框宽度、颜色、圆角、分隔线、环形边框visual-border
特效盒阴影、透明度、混合模式、背景模糊、滤镜visual-effects
SVG用于SVG和图标样式的fill、stroke、stroke-widthvisual-svg

Effects & Interactivity

特效与交互

TopicDescriptionReference
Transition & AnimationCSS transitions, animation keyframes, reduced motioneffects-transition-animation
Visibility & InteractivityVisibility, cursor, pointer-events, user-select, z-indexeffects-visibility-interactivity
Form Controlsaccent-color, appearance, caret-color, resizeeffects-form-controls
Scroll Snapscroll-snap-type, scroll-snap-align for carouselseffects-scroll-snap
主题描述参考
过渡与动画CSS过渡、动画关键帧、减少动画effects-transition-animation
可见性与交互可见性、光标、指针事件、用户选择、z-indexeffects-visibility-interactivity
表单控件accent-color、外观、光标颜色、调整大小effects-form-controls
滚动捕捉用于轮播的scroll-snap-type、scroll-snap-aligneffects-scroll-snap

Features

功能特性

Dark Mode

暗色模式

TopicDescriptionReference
Dark ModeImplementing dark mode with the dark variant and custom strategiesfeatures-dark-mode
主题描述参考
暗色模式使用dark变体和自定义策略实现暗色模式features-dark-mode

Migration

迁移

TopicDescriptionReference
Upgrade GuideMigrating from v3 to v4, breaking changes, rename mappingsfeatures-upgrade
主题描述参考
升级指南从v3迁移到v4、破坏性变更、重命名映射features-upgrade

Customization

自定义

TopicDescriptionReference
Custom StylesAdding custom styles, utilities, variants, and working with arbitrary valuesfeatures-custom-styles
Functions & DirectivesTailwind's CSS directives and functions for working with your design systemfeatures-functions-directives
Content DetectionHow Tailwind detects classes and how to customize content scanningfeatures-content-detection
主题描述参考
自定义样式添加自定义样式、工具类、变体及处理任意值features-custom-styles
函数与指令Tailwind用于设计系统的CSS指令和函数features-functions-directives
内容检测Tailwind如何检测类及自定义内容扫描的方式features-content-detection

Best Practices

最佳实践

TopicDescriptionReference
Utility PatternsManaging duplication, conflicts, important modifier, when to use componentsbest-practices-utility-patterns
主题描述参考
工具类模式管理重复、冲突、重要修饰符、何时使用组件best-practices-utility-patterns

Key Recommendations

关键建议

  • Use utility classes directly in markup - Compose designs by combining utilities
  • Customize with theme variables - Use
    @theme
    directive to define design tokens
  • Mobile-first responsive design - Use unprefixed utilities for mobile, prefixed for breakpoints
  • Use complete class names - Never construct classes dynamically with string interpolation
  • Leverage variants - Stack variants for complex conditional styling
  • Prefer CSS-first configuration - Use
    @theme
    ,
    @utility
    , and
    @custom-variant
    over JavaScript configs
  • 直接在标记中使用工具类 - 通过组合工具类完成设计
  • 使用主题变量自定义 - 使用
    @theme
    指令定义设计令牌
  • 移动优先的响应式设计 - 未加前缀的工具类用于移动端,带前缀的用于断点
  • 使用完整类名 - 永远不要通过字符串插值动态构造类
  • 利用变体 - 堆叠变体实现复杂的条件样式
  • 优先选择基于CSS的配置 - 使用
    @theme
    @utility
    @custom-variant
    而非JavaScript配置