CSS - ClipPath

Aus Wikizone
Wechseln zu: Navigation, Suche

Links[Bearbeiten]

https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path

Beispiele[Bearbeiten]

Bild das immer im gleichen Seitenverhältnis bleibt aber responsiv ist.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Clipped Image</title>
    <style>
        .clipped-container {
          margin: 2em auto;
            position: relative;
            width: 100%;
            max-width: 800px;
            aspect-ratio: 1200 / 800;
            clip-path: polygon(0 0, 100% 0, 100% 85%, 58% 92%, 51% 100%, 43% 94%, 0 100%);
            overflow: hidden;
        }

        .clipped-container img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
    </style>
</head>
<body>
    <div class="clipped-container">
        <img src="image.jpg" alt="Clipped Image">
    </div>
</body>
</html>

Bild mit fester Höhe