clip-path
clip-path
表示属性定义或将剪切路径与相关元素关联。
注意: 作为一个表示属性,clip-path
还有一个对应的 CSS 属性:clip-path
。当两者都指定时,CSS 属性具有优先权。
你可以将此属性与以下 SVG 元素一起使用
示例
html
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<clipPath id="myClip" clipPathUnits="objectBoundingBox">
<circle cx=".5" cy=".5" r=".5" />
</clipPath>
<!-- Top-left: Apply a custom defined clipping path -->
<rect
x="1"
y="1"
width="8"
height="8"
stroke="green"
clip-path="url(#myClip)" />
<!-- Top-right: Apply a CSS basic shape on a fill-box
geometry. This is the same as having a custom clipping
path with a clipPathUnits set to objectBoundingBox -->
<rect
x="11"
y="1"
width="8"
height="8"
stroke="green"
clip-path="circle() fill-box" />
<!-- Bottom-left -->
<rect
x="1"
y="11"
width="8"
height="8"
stroke="green"
clip-path="circle() stroke-box" />
<!-- Bottom-right: Apply a CSS basic shape on a view-box
geometry. This is the same as having a custom clipping
path with a clipPathUnits set to userSpaceOnUse -->
<rect
x="11"
y="11"
width="8"
height="8"
stroke="green"
clip-path="circle() view-box" />
</svg>
用法说明
值 |
<url> | [ <basic-shape> || <geometry-box> ] | none |
---|---|
默认值 | none |
可动画的 | 是 |
- <geometry-box>
-
附加信息,用于说明
<basic-shape>
如何应用于元素:fill-box
表示使用对象的边界框;stroke-box
表示使用带有描边的对象边界框;view-box
表示使用最近的 SVG 视口作为参考框。
注意: 有关 clip-path 语法的更多详细信息,请参阅 CSS 属性 clip-path
参考页面。
规范
规范 |
---|
CSS 蒙版模块 Level 1 # the-clip-path |
浏览器兼容性
加载中…