Skip to content

Border Radius 边框半径

控制元素边框半径的实用工具。

ClassProperties

基本用法

圆角

使用类似 rounded-smroundedrounded-lg 这样的工具来为元素应用不同的边框半径大小。

rounded

rounded-md

rounded-lg

rounded-full

html
<div class="rounded ..."></div>
<div class="rounded-md ..."></div>
<div class="rounded-lg ..."></div>
<div class="rounded-full ..."></div>

药丸按钮

使用 rounded-full 实用程序创建药丸按钮。

rounded-full

html
<button class="rounded-full ...">Save Changes</button>

直角

使用 rounded-none 来移除元素的现有边框半径。

rounded-none

html
<button class="rounded-none ...">Save Changes</button>

这通常用于移除在较小的断点应用的边框半径。

分别对两侧进行圆角处理

使用 rounded-{t|r|b|l}{-size?} 来只舍入元素的一侧。

rounded-t-lg

rounded-r-lg

rounded-b-lg

rounded-l-lg

html
<div class="rounded-t-lg ..."></div>
<div class="rounded-r-lg ..."></div>
<div class="rounded-b-lg ..."></div>
<div class="rounded-l-lg ..."></div>

分别进行圆角处理

使用 rounded-{tl|tr|br|bl}{-size?} 来只圆角一个元素。

rounded-tl-lg

rounded-tr-lg

rounded-br-lg

rounded-bl-lg

html
<div class="rounded-tl-lg ..."></div>
<div class="rounded-tr-lg ..."></div>
<div class="rounded-br-lg ..."></div>
<div class="rounded-bl-lg ..."></div>

使用逻辑属性

使用 rounded-{s|e|ss|se|es|ee}{-size?} 实用程序使用逻辑属性设置边框半径,这些属性根据文本方向映射到相应的角落。

Left-to-right

Right-to-left

html
<div dir="ltr">
	<div class="rounded-s-lg ..."></div>
	<div>
		<div dir="rtl">
			<div class="rounded-s-lg ..."></div>
			<div></div>
		</div>
	</div>
</div>

这里列出了所有可用的边框颜色逻辑属性实用程序及其在 LTR 和 RTL 模式下的物理属性等效物。

ClassLeft-to-rightRight-to-left
rounded-s-*rounded-l-*rounded-r-*
rounded-e-*rounded-r-*rounded-l-*
rounded-ss-*rounded-tl-*rounded-tr-*
rounded-se-*rounded-tr-*rounded-tl-*
rounded-es-*rounded-bl-*rounded-br-*
rounded-ee-*rounded-br-*rounded-bl-*

为了更好地控制,您还可以使用 LTR 和 RTL 修饰符,有条件地应用特定样式,具体取决于当前的文本方向。

有条件地应用

悬停、焦点和其他状态

Tailwind 允许您使用变体修饰符在不同状态下有条件地应用实用程序类。例如,使用 hover:rounded-lg 只在悬停时应用 rounded-lg 实用程序。

html
<div class="rounded hover:rounded-lg">
	<!-- ... -->
</div>

有关所有可用状态修饰符的完整列表,请查看悬停、焦点和其他状态文档。

断点和媒体查询

您还可以使用变体修饰符来针对响应式断点、深色模式、prefers-reduced-motion 等媒体查询进行定位。例如,使用 md:rounded-lg 仅在中等屏幕尺寸及以上应用 rounded-lg 实用程序。

html
<div class="rounded md:rounded-lg">
	<!-- ... -->
</div>

要了解更多信息,请查看有关响应式设计深色模式其他媒体查询修饰符的文档。

使用自定义值

定制您的主题

默认情况下,Tailwind 提供了五个边框半径大小的实用工具。您可以通过编辑 Tailwind 配置文件的 theme.borderRadius 部分来更改、添加或删除这些内容。

js
module.exports = {
	theme: {
		borderRadius: {
			none: '0',
			sm: '0.125rem', 
			DEFAULT: '0.25rem', 
			DEFAULT: '4px', 
			md: '0.375rem', 
			lg: '0.5rem', 
			full: '9999px', 
			large: '12px', 
		},
	},
}

有关自定义默认主题的更多信息,请参阅主题自定义文档。

任意值

如果您需要使用一个与主题无关的 border-radius 值,可以使用方括号来根据任意值动态生成属性。

html
<p class="rounded-[12px]">
	<!-- ... -->
</p>

有关任意值支持的更多信息,请参阅任意值文档。

Released under the MIT License.