任务是定义背景的绘制区域。 CSS background-clip 属性倾向于对受害程度进行平方测量,以勾勒出任何网页背景的绘制空间。它指定在此范围内,我们将根据其内容或其中包含的图像/视频修改网页的背景。
句法:
background-clip: border-box/padding-box/content-box/initial/inherit;
此属性包含的值:
对于各种函数,主要测量此属性的五个值,让我们检查它们的工作方式和方式。
Value |
Description |
border-box | This worth is ready by default conjointly once there’s no declaration, and it specifies the painting space behind the border. |
padding-box | It specifies the painting space to be among the border not over it. |
content-box | It specifies the painting space to be solely among the content we’ve written. |
initial | Whatever be the property worth declared earlier it simply set it once more to its default worth suggests that border-box worth. |
inherit | It works because it has named it inherits the painting space of its parent component. |
例子:
- 使用属性值:
HTML
Example for background-clip Property
This value is set by default also when there is
no declaration and it specifies the painting
area behind the border.
background-clip: padding-box:
It specifies the painting area to
be within the border not over it.
background-clip: content-box:
It specifies the painting g area to be only
within the content we have written.
HTML
Flip background-clip with JavaScript
输出:
- 使用 JavaScript 翻转值:
HTML
Flip background-clip with JavaScript
输出: