box-decoration-break - CSS: Cascading Style Sheets 编辑

The box-decoration-break CSS property specifies how an element's fragments should be rendered when broken across multiple lines, columns, or pages.

The specified value will impact the appearance of the following properties:

Syntax

/* Keyword values */
box-decoration-break: slice;
box-decoration-break: clone;

/* Global values */
box-decoration-break: initial;
box-decoration-break: inherit;
box-decoration-break: unset;

The box-decoration-break property is specified as one of the keyword values listed below.

Values

slice
The element is initially rendered as if its box were not fragmented, after which the rendering for this hypothetical box is sliced into pieces for each line/column/page. Note that the hypothetical box can be different for each fragment since it uses its own height if the break occurs in the inline direction, and its own width if the break occurs in the block direction. See the CSS specification for details.
clone
Each box fragment is rendered independently with the specified border, padding, and margin wrapping each fragment. The border-radius, border-image, and box-shadow are applied to each fragment independently. The background is also drawn independently for each fragment, which means that a background image with background-repeat: no-repeat may nevertheless repeat multiple times.

Formal definition

Initial valueslice
Applies toall elements
Inheritedno
Computed valueas specified
Animation typediscrete

Formal syntax

slice | clone

Examples

Inline box fragments

An inline element that contains line breaks styled with:

.example {
  background: linear-gradient(to bottom right, yellow, green);
  box-shadow:
    8px 8px 10px 0px deeppink,
    -5px -5px 5px 0px blue,
    5px 5px 15px 0px yellow;
  padding: 0em 1em;
  border-radius: 16px;
  border-style: solid;
  margin-left: 10px;
  font: 24px sans-serif;
  line-height: 2;
}

...
<span class="example">The<br>quick<br>orange fox</span>

... results in:

A screenshot of the rendering of an inline element styled with box-decoration-break:slice and styles given in the example.

Adding box-decoration-break: clone to the above styles:

-webkit-box-decoration-break: clone;
box-decoration-break: clone;

... results in:

A screenshot of the rendering of an inline element styled with box-decoration-break:clone and styles given in the example

You can try the two inline examples above in your browser.

Here's an example of an inline element using a large border-radius value. The second "iM" has a line-break between the "i" and the "M". For comparison, the first "iM" is without line breaks. Note that if you stack the rendering of the two fragments horizontally next to each other it will result in the non-fragmented rendering.

A screenshot of the rendering of the second inline element example.

Try the above example in your browser.

Block box fragments

A block element with similar styles as above and no fragmentation results in:

A screenshot of the rendering of the block element used in the examples without any fragmentation.

Fragmenting the above block into three columns results in:

A screenshot of the rendering of the fragmented block used in the examples styled with box-decoration-break:slice.

Note that stacking these pieces vertically will result in the non-fragmented rendering.

Now, the same example but styled with box-decoration-break: clone results in:

A screenshot of the rendering of the fragmented block used in the examples styled with box-decoration-break:clone.

Note here that each fragment has an identical replicated border, box-shadow, and background.

You can try the block examples above in your browser.

Specifications

SpecificationStatusComment
CSS Fragmentation Module Level 3
The definition of 'box-decoration-break' in that specification.
Candidate RecommendationInitial definition.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:151 次

字数:9395

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文