1. 布局
  2. 盒装饰中断

Quick reference

Class
Properties
box-decoration-clonebox-decoration-break: clone;
box-decoration-slicebox-decoration-break: slice;

基本用法

¥Basic usage

设置盒装饰中断

¥Setting the box decoration break

使用 box-decoration-slicebox-decoration-clone 工具来控制是否应将诸如背景、边框、边框图片、框阴影、剪辑路径、边距和填充等属性渲染为就好像该元素是一个连续片段或不同的块一样。

¥Use the box-decoration-slice and box-decoration-clone utilities to control whether properties like background, border, border-image, box-shadow, clip-path, margin, and padding should be rendered as if the element were one continuous fragment, or distinct blocks.

box-decoration-slice

Hello
World

box-decoration-clone

Hello
World
<span class="box-decoration-slice bg-gradient-to-r from-indigo-600 to-pink-500 text-white px-2 ...">
  Hello<br />
  World
</span>
<span class="box-decoration-clone bg-gradient-to-r from-indigo-600 to-pink-500 text-white px-2 ...">
  Hello<br />
  World
</span>

有条件地应用

悬停、聚焦和其他状态

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:box-decoration-slice to only apply the box-decoration-slice utility on hover.

<div class="box-decoration-clone hover:box-decoration-slice">
  <!-- ... -->
</div>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

断点和媒体查询

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:box-decoration-slice to apply the box-decoration-slice utility at only medium screen sizes and above.

<div class="box-decoration-clone md:box-decoration-slice">
  <!-- ... -->
</div>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.