- Export your SVG
- Chuck it inline on your page somewhere
- Add
width="0px" height="0px" style="position:absolute;pointer-events:none"to the svg element to make it not visible on the page. - Put the
<path>element within a<clipPath>element - Add an ID and
clipPathUnits="objectBoundingBox"to the clipPath element. - Convert the path data to 'relative' using this site: https://yoksel.github.io/relative-clip-path/ (when exported, path values will be 'absolute', and reference pixel dimensions essentially, this makes it truly responsive).
- Reference the ID you added for the clipPath in your CSS.
Last active
October 15, 2025 06:17
-
-
Save JezDriver/5d3f329a193ff3b19f39683b4f89fd69 to your computer and use it in GitHub Desktop.
Responsively sizing clip-path using SVG #svg #html #css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <svg width="0px" height="0px" style="position:absolute;pointer-events:none" viewBox="0 0 1440 250" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><clipPath id="example-clip" clipPathUnits="objectBoundingBox"><path d="M0,0 c0.166,0.027,0.333,0.04,0.5,0.04 c0.167,0,0.334,-0.013,0.5,-0.04 v1 c-0.167,-0.027,-0.334,-0.04,-0.5,-0.04 c-0.167,0,-0.333,0.013,-0.5,0.04 V0"/></clipPath></svg> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .element { | |
| clip-path: url(#example-clip); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment