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 |
瀏覽器相容性
載入中…