All effectsVisual styles

Image Mask

图像蒙版

Only the portion of an image inside a custom shape remains visible.

Look at the shape that crops the artwork

Where to use it

Fit a photo or illustration into artwork with a distinct silhouette. Choose a silhouette that belongs to the subject and position the crop so the important detail stays inside it at every breakpoint.

Practical example

A camera shop displays a sample photo inside a shutter-shaped cutout beside the lens specifications. The crop keeps the bird in the center of the opening as the product page narrows.

AI prompt

Apply an Image Mask to [target artwork]. Use clip-path for a hard-edged silhouette or mask-image for a soft alpha edge. Keep object-fit and object-position controllable, and preserve the original image alternative text.

Example code

Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.

View HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Image Mask</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .visual-specimen {
      width: min(100%, 290px);
      height: 124px;
      display: grid;
      place-items: center;
      position: relative;
      isolation: isolate;
    }
    .masked-art {
      position: relative; width: min(100%, 173px); height: 110px;
      background: #8ec5c8; overflow: hidden;
      clip-path: polygon(25% 0, 75% 0, 100% 42%, 84% 100%, 15% 100%, 0 42%);
    }
    .masked-art i { position: absolute; top: 15px; right: 32px; width: 37px; aspect-ratio: 1; border-radius: 50%; background: #f8d99c; }
    .masked-art i:last-child {
      inset: 40% -5% 0; width: auto; aspect-ratio: auto; border-radius: 0; background: #2c6368;
      clip-path: polygon(0 80%, 29% 25%, 44% 62%, 66% 0, 100% 81%, 100% 100%, 0 100%);
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="visual-specimen" aria-hidden="true"><div class="masked-art"><i></i><i></i></div></div>
  </main>
</body>
</html>

Original example by UI Skills