diff --git a/utilities/variants.md b/utilities/variants.md index 66e33319..8ff44b1d 100644 --- a/utilities/variants.md +++ b/utilities/variants.md @@ -1,53 +1,52 @@ -[pseudo-selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes +[pseudo-selector]: https://developer.mozilla.org/zh-CN/docs/Web/CSS/Pseudo-classes -# Variants +# 可变修饰 {#variants} -Variants allow you to specify under what circumstances your utilities will be activated. +可变修饰允许你在特定情况下启用你的工具类。 -You may use the screen size, system theme, or any [pseudo-selector], such as `:hover`. +你可以使用屏幕大小,系统主题,或者任何伪选择器,比如 `:hover`。 -You specify a variant by using the `:` separator, and you can combine them arbitrarily as in: +你可以使用 `:` 操作符指定一个可变修饰,也可以将它们任意组合起来,如下: ``` sm:bg-red-500 sm:hover:bg-green-300 dark:bg-white ``` -## Screen Variants +## 屏幕可变修饰 {#screen-variants} -### Mobile First +### 移动设备优先 {#mobile-first} -| Variant | Rule | Description | +| 可变修饰 | 规则 | 描述 | | :------ | :--- | :---------- | -| sm | @media (min-width: 640px) { ... } | Enable utility when the screen width is greater than 640px | -| md | @media (min-width: 768px) { ... } | Enable utility when the screen width is greater than 768px | -| lg | @media (min-width: 1024px) { ... } | Enable utility when the screen width is greater than 1024px | -| xl | @media (min-width: 1280px) { ... } | Enable utility when the screen width is greater than 1280px | -| 2xl | @media (min-width: 1536px) { ... } | Enable utility when the screen width is greater than 1536px | +| sm | @media (min-width: 640px) { ... } | 屏幕宽度不小于 640px 时启用工具 | +| md | @media (min-width: 768px) { ... } | 屏幕宽度不小于 768px 时启用工具 | +| lg | @media (min-width: 1024px) { ... } | 屏幕宽度不小于 1024px 时启用工具 | +| xl | @media (min-width: 1280px) { ... } | 屏幕宽度不小于 1280px 时启用工具 | +| 2xl | @media (min-width: 1536px) { ... } | 屏幕宽度不小于 1536px 时启用工具 | -### Desktop First +### 桌面设备优先 {#desktop-first} -| Variant | Rule | Description | +| 可变修饰 | 规则 | 描述 | | :------ | :--- | :---------- | -| * { ... }` | Targets children nodes. | -| siblings | `.${utility} ~ * { ... }` | Targets siblings nodes . | -| sibling | `.${utility} + * { ... }` | Targets first sibling node. | +| svg | `.${utility} svg { ... }` | svg 目标节点。 | +| all | `.${utility} * { ... }` | 所有目标节点。 | +| children | `.${utility} > * { ... }` | 目标子节点。 | +| siblings | `.${utility} ~ * { ... }` | 目标兄弟节点。 | +| sibling | `.${utility} + * { ... }` | 目标首个兄弟节点。 | -### Media Query +### 媒体查询 {#media-query} -| Variant | Rule | Description | +| 可变修饰 | 规则 | 描述 | | :------ | :--- | :---------- | -| motion-safe | `@media (prefers-reduced-motion: no-preference) { ... }` | Targets the prefers-reduced-motion: no-preference media query. -| motion-reduce | `@media (prefers-reduced-motion: reduce) { ... }` | Targets the prefers-reduced-motion: reduce media query. +| motion-safe | `@media (prefers-reduced-motion: no-preference) { ... }` | 基于 prefers-reduced-motion: no-preference 的媒体查询目标。 | +| motion-reduce | `@media (prefers-reduced-motion: reduce) { ... }` | 基于 prefers-reduced-motion: reduce 的媒体查询目标。| -## Theme Variants +## 主题可变修饰 {#pseudo-selectors} -### Default +### 默认值 {#default} -| Variant | Rule | Description | +| 可变修饰 | 规则 | 描述 | | :------ | :--- | :---------- | -| dark | `@media (prefers-color-scheme: dark) { ... }` or `.dark .{utility} { ... }` | Enable utility base on user configuration | -| light | `@media (prefers-color-scheme: light) { ... }` or `.light .{utility} { ... }` | Enable utility base on user configuration | +| dark | `@media (prefers-color-scheme: dark) { ... }` or `.dark .{utility} { ... }` | 用户自定义配置以启用工具 | +| light | `@media (prefers-color-scheme: light) { ... }` or `.light .{utility} { ... }` | 用户自定义配置以启用工具 | -### Following System +### 跟随系统 {#following-system} -| Variant | Rule | Description | +| 可变修饰 | 规则 | 描述 | | :------ | :--- | :---------- | -| @dark | `@media (prefers-color-scheme: dark) { ... }` | Enable utility when the system turns on dark mode | -| @light | `@media (prefers-color-scheme: light) { ... }` | Enable utility when the system turns on light mode | +| @dark | `@media (prefers-color-scheme: dark) { ... }` | 打开亮色模式启用工具 | +| @light | `@media (prefers-color-scheme: light) { ... }` | 打开暗色模式启用工具 | -### Following Application +### 跟随应用程序 {#following-application} -| Variant | Rule | Description | +| 可变修饰 | 规则 | 描述 | | :------ | :--- | :---------- | -| .dark | `.dark .{utility} { ... }` | Enable utility base on application dark mode | -| .light | `.light .{utility} { ... }` | Enable utility base on application light mode | +| .dark | `.dark .{utility} { ... }` | 基于亮色模式下启用工具 | +| .light | `.light .{utility} { ... }` | 基于暗色模式下启用工具 |