The clip-path
property in CSS allows you to clip an element to a specific shape. It can be used to create advanced graphical effects, such as masking parts of elements or creating irregular shapes.
Examples of using clip-path
:
- Clipping to a rectangle shape:
.element { clip-path: inset(10px 20px 30px 40px); }
- Clipping to a circle shape:
.element { clip-path: circle(50% at 50% 50%); }
- Clipping to a polygon shape:
.element { clip-path: polygon(50% 0%, 0% 100%, 100% 100%); }
Applications of clip-path
:
- Creating masks and masking effects.
- Clipping images and elements to irregular shapes.
- Creating advanced graphical effects in user interfaces.
Example:
<img src="example.jpg" class="element" style="clip-path: circle(50% at 50% 50%);">