clip-path
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2021.
Das Präsentationsattribut clip-path
definiert oder verbindet einen Clipping-Pfad mit dem Element, auf das es sich bezieht.
Hinweis:
Als Präsentationsattribut kann clip-path
als CSS-Eigenschaft verwendet werden.
Dieses Attribut kann mit den folgenden SVG-Elementen verwendet werden:
Beispiel
<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>
Anwendungshinweise
Wert |
<url> | [ <basic-shape> ||
<geometry-box> ] | none
|
---|---|
Standardwert | none |
Animierbar | Ja |
- <geometry-box>
-
Zusätzliche Informationen, um anzugeben, wie eine
<basic-shape>
auf ein Element angewendet wird:fill-box
gibt an, dass die Begrenzungsbox des Objekts verwendet wird;stroke-box
gibt an, dass die Begrenzungsbox des Objekts, erweitert um den Strich, verwendet wird;view-box
gibt an, dass der nächstgelegene SVG-Ansichtsbereich als Referenzbox verwendet wird.
Hinweis:
Weitere Details zur clip-path-Syntax finden Sie auf der CSS-Eigenschaftsreferenzseite clip-path
.
Spezifikationen
Specification |
---|
CSS Masking Module Level 1 # the-clip-path |
Browser-Kompatibilität
BCD tables only load in the browser
Siehe auch
- CSS
clip-path
Eigenschaft