CSS 属性
全部展开 | 全部折叠
CSS 规则

CSS3 background-clip 属性

主题:CSS3 属性参考上一页|下一页

说明

background-clip CSS 属性指定元素的背景(颜色或图像)是否延伸到其边框之下。

下表总结了此属性的使用上下文和版本历史记录。

默认值: border-box
适用于:
所有元素。 它也适用于 ::first-letter::first-line
继承: No
动画: No. 参见动画属性
版本: New in CSS3

语法

属性的语法如下:

background-clip: 
border-box | padding-box | content-box | initial | inherit

下面的示例显示了 background-clip 属性的作用。

.box {
    width: 250px;
    height: 150px;
    padding: 10px;
    border: 6px dashed #333;
    background: orange;
    background-clip: content-box;
}

属性值

下表描述了该属性的值。

说明
border-box 指定背景延伸到边框的外边缘。 背景绘制在边框下方。 这是默认值。
padding-box 指定背景延伸到填充的外边缘。 边框下方没有绘制背景。
content-box 指定仅在内容框内绘制(剪切到)背景。 在边框和填充区域下方不绘制背景。
initial 将此属性设置为其默认值。
inherit 如果指定,则关联元素采用其父元素 background-clip 属性的 计算值

浏览器兼容性

所有主要的现代浏览器都支持 background-clip 属性。

Browsers Icon

基本支持—

  • Firefox 4+
  • Google Chrome 4+
  • Internet Explorer 9+
  • Apple Safari 3+
  • Opera 10.5+

进一步阅读

请参阅以下教程: CSS3 背景, CSS3 背景.

相关属性: background, background-attachment, background-color, background-image, background-origin, background-position, background-repeat, background-size.

Advertisements