QP School

Full Version: CSS clip path
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.