border-image-slice - CSS(层叠样式表) 编辑
概要
通过border-image-source
引用边框图片后,border-image-slice
属性会将图片分割为9个区域:四个角,四个边(edges)以及中心区域。四条切片线,从它们各自的侧面设置给定距离,控制区域的大小。
上图说明了每个区域的位置。
- 区域 1-4 为角区域(corner region)。 每一个都用一次来形成最终边界图像的角点。(Each one is used a single time to form the corners of the final border image.)
- 区域 5-8 边区域(edge region)。在最终的边框图像中重复,缩放或修改它们以匹配元素的尺寸。(These are repeated, scaled, or otherwise modified in the final border image to match the dimensions of the element.)
- 区域 9 为中心区域( middle region)。它在默认情况下会被丢弃,但如果设置了关键字
fill
,则会将其用作背景图像。(It is discarded by default, but is used like a background image if the keywordfill
is set.)
中间的区域将不会被边框使用,但当设置有 fill 关键词时将会被作为 background-image。这个关键词可以被设置在属性的任何一个位置(前面、后面或者两个值之间)
border-image-repeat
, border-image-width
, border-image-outset
属性则定义这些图片将如何使用。
语法
/* 所有的边 */
border-image-slice: 30%;
/* 垂直方向 | 水平方向 */
border-image-slice: 10% 30%;
/* 顶部 | 水平方向 | 底部 */
border-image-slice: 30 30% 45;
/* 上 右 下 左 */
border-image-slice: 7 12 14 5;
/* 使用fill(fill可以放在任意位置) */
border-image-slice: 10% fill 7 12;
/* Global values */
border-image-slice: inherit;
border-image-slice: initial;
border-image-slice: unset;
值
- slice
- Is a
<number>
or a<percentage>
of the offset for the four slicing lines. The<number>
represents pixels for raster images and coordinates for vector images. Also,<percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to100%
. - horizontal
- Is a
<number>
or a<percentage>
of the offset for the two slicing lines corresponding to the horizontal edges, the right and the left ones. The<number>
represents pixels for raster images and coordinates for vector images. Also,<percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to100%
. - vertical
- Is a
<number>
or a<percentage>
of the offset for the two slicing lines corresponding to the vertical edges, the top and the bottom ones. The<number>
represents pixels for raster images and coordinates for vector images. Also,<percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to100%
. - top
- Is a
<number>
or a<percentage>
of the offset for the top slicing line. The<number>
represents pixels for raster images and coordinates for vector images. Also,<percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to100%
. - bottom
- Is a
<number>
or a<percentage>
of the offset for the bottom slicing line. The<number>
represents pixels for raster images and coordinates for vector images. Also,<percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to100%
. - right
- Is a
<number>
or a<percentage>
of the offset for the right slicing line. The<number>
represents pixels for raster images and coordinates for vector images. Also,<percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to100%
. - left
- Is a
<number>
or a<percentage>
of the offset for the left slicing line. The<number>
represents pixels for raster images and coordinates for vector images. Also,<percentage>
values are relative to the height or width of the image, whichever is adequate. Negative values are invalid and values greater than the relevant size, height or width, are clamped to100%
. fill
- Is a keyword whose presence forces the use of the middle image slice to be displayed over the background image, its size and height are resized like those of the top and left image slices, respectively.
inherit
- Is a keyword indicating that all four values are inherited from their parent's element calculated value.
形式语法
<number-percentage>{1,4} && fill?where
<number-percentage> = <number> | <percentage>
规范
Specification | Status | Comment |
---|---|---|
CSS Backgrounds and Borders Module Level 3 border-image-slice | Candidate Recommendation | Initial defintion |
浏览器兼容性
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论