Yogesh Chauhan's Blog

clip and clip-path properties in CSS

in CSS on March 27, 2021

clip CSS property (deprecated)

We can use clip property to show only a portion of any element for e.g. an image.

We can apply clip property only to elements with position property set to fixed or absolute.

We can clip the element in the shape of a rectangle using rect(top corner, right corner, bottom corner, left corner).

We can not clip element if the overflow property has been set as visible as its like telling browsers to do two completely opposite things.

The clip property still works but it won’t work forever. Try to use clip-path property instead.

clip-path CSS property

clip-path property is a newer and better version of clip.

With the clip-path property we can clip/show different shaped regions, not just a rectangle.

The biggest advantage of clip-path property is that it works really well with svg elements which just boost our imagination.

clip-path CSS property Examples

clip-path-circle-50

clip-path: circle(40%)

clip-path:ellipse

clip-path:polygon

Checkout some really good SVG clip-path examples on MDN.


amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS? #Aug 1 What is Zdog? #Aug 1 How to add before after image effect using pure CSS? #Jul 31 Add animation to your skills bar using CSS #Jul 31 Use SwiperJS to create mobile touch sliders fast
You might also like these
Object destructuring in JavaScript: Unpacking fields from objects passed as function parameterJavaScriptThe Difference Between isNaN() Method And isNaN() Function In JavaScriptJavaScriptHow to make flexbox items of the same size?CSSLearn to create your skill bar using CSSCSSHow to get start index and end index (as int) of substring in Swift?SwiftPHP Variables ScopePHPThe SQL UNION OperatorSQL/MySQLHow to Block IPs and User Agents using code in Drupal or WordPress?DrupalResponsive Masonry Grid using CSS columns PropertyCSSIntroduction to components and templates Part 1: Component MetadataAngularHow to change CSS with jQuery?CSSWHERE Clause in PostgresPostgres