
边框
用于创建带有框阴影的轮廓环的工具。
使用 ring-* 工具为元素应用特定厚度的实心盒子阴影。环默认是半透明蓝色,类似于许多系统中的默认焦点环样式。
🌐 Use the ring-* utilities to apply solid box-shadow of a specific thickness to an element. Rings are a semi-transparent blue color by default, similar to the default focus ring style in many systems.
ring-2
ring
ring-4
<button class="... ring-offset-2 ring-2">Button A</button>
<button class="... ring-offset-2 ring">Button B</button>
<button class="... ring-offset-2 ring-4">Button C</button>
环形工具可以与常规的 shadow-* 工具优雅地组合,并且可以在同一元素上组合使用。
🌐 Ring utilities compose gracefully with regular shadow-* utilities and can be combined on the same element.
你还可以使用 ringColor、ringOpacity 和 ringOffsetWidth 工具来控制环的颜色、不透明度和偏移。
🌐 You can also control the color, opacity, and offset of rings using the ringColor, ringOpacity, and ringOffsetWidth utilities.
环宽实用程序使使用自定义焦点环变得容易,只需在任何 ring-* 实用程序的开头添加 focus: 即可。
🌐 The ring width utilities make it easy to use custom focus rings by adding focus: to the beginning of any ring-* utility.
Focus this button to see the ring appear
<button class="... focus:ring-2">Save Changes</button>
focus 变体默认也适用于 ringColor、ringOpacity、ringOffsetWidth 和 ringOffsetColor 工具。
🌐 The focus variant is enabled by default for the ringColor, ringOpacity, ringOffsetWidth, and ringOffsetColor utilities as well.
使用 ring-inset 工具可以强制将环渲染在元素的内部而不是外部。这对于屏幕边缘的元素特别有用,因为环的部分可能无法显示。
🌐 Use the ring-inset utility to force a ring to render on the inside of an element instead of the outside. This can be useful for elements at the edge of the screen where part of the ring wouldn’t be visible.
<button class="... ring-2 ring-pink-300 ring-inset"> Save Changes </button><button class="... ring-2 ring-pink-500 ring-inset"> Save Changes </button>
Tailwind 允许你使用变体修饰符在不同状态下有条件地应用工具类。例如,使用hover:ring-4 仅在 hover 时应用 ring-4 工具。
<div class="ring-2 hover:ring-4">
<!-- ... -->
</div>
有关所有可用状态修饰符的完整列表,请查看悬停、聚焦、以及其他状态 文档。
你还可以使用变体修饰符来定位媒体查询,例如响应式断点、暗黑模式、首选减少运动等。例如,使用 md:ring-4 仅在中等屏幕尺寸及以上时应用 ring-4 工具。
<div class="ring-2 md:ring-4">
<!-- ... -->
</div>
要了解更多信息,请查看有关 响应式设计、暗黑模式、以及 其他媒体查询修饰符 的文档。
默认情况下,Tailwind 包含一些通用的 ring-width 工具。你可以通过编辑 tailwind.config.js 文件中的 theme.ringWidth 或 theme.extend.ringWidth 来自定义这些值。
🌐 By default, Tailwind includes a handful of general purpose ring-width utilities. You can customize these values by editing theme.ringWidth or theme.extend.ringWidth in your tailwind.config.js file.
module.exports = {
theme: {
extend: {
ringWidth: {
'10': '10px',
}
}
}
}
在主题自定义文档中了解有关自定义默认主题的更多信息。
🌐 Learn more about customizing the default theme in the theme customization documentation.
如果你需要使用一次性的 ring 值,而该值没有必要包含在你的主题中,请使用方括号动态生成属性,使用任意值。
<div class="ring-[10px]">
<!-- ... -->
</div>
在 任意值 文档中了解有关任意值支持的更多信息。