SVG
stroke-width
用于设置 SVG 元素描边宽度的工具。
| 类 | 样式 |
|---|---|
stroke-<number> | stroke-width: <number>; |
stroke-(length:<custom-property>) | stroke-width: var(<custom-property>); |
stroke-[<value>] | stroke-width: <value>; |
示例(Examples)
基本示例(Basic example)
使用 stroke-<number> 工具,例如 stroke-1 和 stroke-2,来设置 SVG 的描边宽度:
🌐 Use stroke-<number> utilities like stroke-1 and stroke-2 to set the stroke width of an SVG:
<svg class="stroke-1 ..."></svg><svg class="stroke-2 ..."></svg>这对于像 Heroicons 这样的图标集的样式设置非常有用。
🌐 This can be useful for styling icon sets like Heroicons.
使用自定义值(Using a custom value)
使用 stroke-[<value>] 语法 根据完全自定义的值设置 stroke width:
<div class="stroke-[1.5] ..."> <!-- ... --></div>对于 CSS 变量,还可以使用 stroke-(length:<custom-property>) 语法:
<div class="stroke-(length:--my-stroke-width) ..."> <!-- ... --></div>这只是简写,用于 stroke-[length:var(<custom-property>)] 它会自动为你添加 var() 函数。
响应式设计(Responsive design)
在 stroke-width 工具前面使用断点变体如 md: 仅在 medium 屏幕尺寸及以上时应用工具:
<div class="stroke-1 md:stroke-2 ..."> <!-- ... --></div>请参阅 变体文档 详细了解如何使用变体。