作者: | Noel Rappin |
语言: | 英文 |
出版年份: | 2021 |
编程语言: | CSS |
下载链接: |
书籍均收集自互联网,仅供学习和研究使用,请莫用于商业用途。谢谢合作。 |
Modern CSS with Tailwind 是一本面向已具备基础 CSS 知识的开发者、系统介绍 Tailwind CSS 2.0 的实用指南。全书共 8 章,约 260 页,采用“边讲边做”的方式,从安装、基础概念、排版、布局、响应式设计到深度定制,帮助读者快速掌握“无命名”的原子化 CSS 开发范式。书中配有 React 与 Rails 两套示例代码,可在线运行。
tailwind init
生成配置文件 → 引入 @tailwind base; @tailwind components; @tailwind utilities;
→ 编译即可使用。m-4
仅设 margin。@apply
指令抽取公共样式。hover:
、focus:
、sm:
等,实现交互与响应式。text-xs
到 text-9xl
共 13 级,统一行高。@tailwindcss/typography
一键生成文章排版;@tailwindcss/forms
美化原生表单。bg-gradient-to-r from-red-500 to-blue-500
)、图片、裁剪(bg-clip-text
)。w-1/2
、h-screen
、min-h-0
、max-w-xl
等 60+ 组合。mx-auto
居中。.grid-cols-12
12 栏网格,行列合并、间距、流式填充。justify-between
、items-center
、place-content-center
等 20+ 工具类。animate-spin
(旋转)、animate-pulse
(呼吸)、animate-bounce
(弹跳)、animate-ping
(脉冲)。.transition .duration-300 .ease-in-out
与 hover:
/focus:
连用,实现颜色、阴影、位移平滑变化。scale-110
、rotate-45
、translate-x-full
、skew-x-12
,支持原点调整。sm:640px
、md:768px
、lg:1024px
、xl:1280px
、2xl:1536px
,采用“移动优先”策略。text-xl md:text-2xl lg:text-4xl
;hidden lg:block
在移动端隐藏、桌面端显示。tailwind.config.js
的 theme
、variants
、plugins
、corePlugins
。disabled:
、odd:
、motion-reduce:
等 20+ 前缀。prefix:"tw-"
或 important:true
避免命名冲突;用 resolveConfig
在 JavaScript 中读取设计令牌。Modern CSS with Tailwind 以实战案例为线索,全面展示了如何用 Tailwind CSS 在几小时内完成过去需要数天的响应式页面开发,并能在保持高性能的同时实现极致的可定制性。