I'm trying to use the CSS property clip-path
, but I get an Invalid property value
error in Chrome.
Here's a small demo:
.clip-me {
clip-path: inset(0px 50px 50px 0px); /* top, right, bottom, left */
}
<img class="clip-me" src="http://i.stack.imgur.com/MnWjF.png" width="100">
Note: This is different from this question on clip-path does not work with chrome, because it's specifically asking about how to apply clip path using SVG (not CSS)
According to Can I Use, it should work in chrome.
The <top> , <right> , <bottom> , and <left> values may be either a <length> or auto . If any side's value is auto , the element is clipped to that side's inside border edge. The element does not clip (default). This is different from rect(auto, auto, auto, auto) , which clips to the element's inside border edges.
The clip-path CSS property creates a clipping region that sets what part of an element should be shown. Parts that are inside the region are shown, while those outside are hidden.
Support for clip-path in SVG is supported in all browsers with basic SVG support.
Turns out I just needed the -webkit-
prefix (although I don't see it in this list of vendor prefixes)
.clip-me { /* top, right, bottom, left */
-webkit-clip-path: inset(0px 50px 50px 0px);
clip-path: inset(0px 50px 50px 0px);
}
<img class="clip-me" src="http://i.stack.imgur.com/MnWjF.png" width="100">
Update as of Chrome 55, clip-path without the vendor prefix is now supported, but many other browsers still require using -webkit-clip-path
so it's safer to include it for now.
Here's a snapshot of CanIUse (as of 2017), with the additional details in the top right corner of partial support browsers often indicating the need for the -webkit-
prefix
Further Reading:
<clipPath>
ElementIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With