QP School
CSS clip path - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: CSS3 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=5)
+--- Thread: CSS clip path (/showthread.php?tid=5188)



CSS clip path - Qomplainerz - 07-26-2023

Description:

The clip-path property allows you to create custom clipping paths to control the visibility of an element. It's particularly useful for creating unique shapes or revealing parts of an element.

Example:

<!DOCTYPE html>
<html>
<head>
  <title>CSS Clip Path Example</title>
  <style>
    .clipped-element {
      width: 200px;
      height: 200px;
      background-color: lightblue;
      clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    }
  </style>
</head>
<body>
  <div class="clipped-element"></div>
</body>
</html>

Explanation:

In this example, the .clipped-element div has a custom clipping path defined by the clip-path property. The polygon() function creates a diamond shape by specifying the coordinates of the four points (50% 0%, 100% 50%, 50% 100%, and 0% 50%). The element's content is clipped within this diamond shape, giving it a unique appearance.