← Codeschnipsel

Animiertes Inline-SVG – Weihnachtsedition

HTML · von waerp · 25.09.2026

Ein kleiner Weihnachtsbaum mit blinkenden Christbaumkugeln, einem leuchtenden Stern und fallendem Schnee.

HTML
<div class="christmas-scene">

    <svg
        class="christmas-tree"
        viewBox="0 0 300 350"
        xmlns="http://www.w3.org/2000/svg"
        role="img"
        aria-label="Animierter Weihnachtsbaum"
    >

        <!-- Hintergrund -->
        <rect
            width="300"
            height="350"
            rx="20"
            fill="#07111f"
        />

        <!-- Mond -->
        <circle
            cx="240"
            cy="60"
            r="25"
            fill="#fff7d6"
            opacity="0.9"
        />

        <!-- Sterne im Hintergrund -->
        <g fill="#ffffff">
            <circle cx="40" cy="50" r="2" />
            <circle cx="80" cy="85" r="2" />
            <circle cx="150" cy="45" r="2" />
            <circle cx="195" cy="100" r="2" />
            <circle cx="270" cy="125" r="2" />
            <circle cx="30" cy="150" r="1.5" />
        </g>


        <!-- ⭐ Weihnachtsstern -->
        <polygon
            class="tree-star"
            points="
                150,35
                156,52
                175,52
                160,63
                166,82
                150,70
                134,82
                140,63
                125,52
                144,52
            "
            fill="#ffd54a"
        />


        <!-- Baum -->
        <g class="tree">

            <!-- Oberes Dreieck -->
            <polygon
                points="150,70 105,150 195,150"
                fill="#166534"
            />

            <!-- Mittleres Dreieck -->
            <polygon
                points="150,115 75,220 225,220"
                fill="#15803d"
            />

            <!-- Unteres Dreieck -->
            <polygon
                points="150,165 45,290 255,290"
                fill="#166534"
            />

            <!-- Baumstamm -->
            <rect
                x="130"
                y="280"
                width="40"
                height="35"
                rx="4"
                fill="#78350f"
            />

        </g>


        <!-- 🎄 Lichter -->
        <g class="lights">

            <circle cx="130" cy="125" r="6" fill="#ef4444" />
            <circle cx="165" cy="145" r="6" fill="#facc15" />
            <circle cx="110" cy="185" r="6" fill="#38bdf8" />
            <circle cx="180" cy="195" r="6" fill="#f472b6" />
            <circle cx="90" cy="235" r="6" fill="#facc15" />
            <circle cx="145" cy="225" r="6" fill="#ef4444" />
            <circle cx="205" cy="250" r="6" fill="#38bdf8" />
            <circle cx="120" cy="265" r="6" fill="#f472b6" />
            <circle cx="170" cy="270" r="6" fill="#facc15" />

        </g>


        <!-- Schnee auf dem Boden -->
        <ellipse
            cx="150"
            cy="320"
            rx="110"
            ry="15"
            fill="#ffffff"
            opacity="0.9"
        />


        <!-- ❄️ Fallender Schnee -->
        <g class="snow">

            <circle cx="30" cy="20" r="3" />
            <circle cx="70" cy="15" r="2" />
            <circle cx="110" cy="30" r="3" />
            <circle cx="190" cy="20" r="2" />
            <circle cx="225" cy="35" r="3" />
            <circle cx="275" cy="15" r="2" />

        </g>

    </svg>

</div>


<style>

    .christmas-scene {
        display: flex;
        justify-content: center;
        align-items: center;

        min-height: 400px;

        background: #020617;
        overflow: hidden;
    }


    .christmas-tree {
        width: 300px;
        max-width: 90vw;

        filter:
            drop-shadow(0 0 15px rgba(255, 255, 255, 0.15));
    }


    /* ⭐ Stern */
    .tree-star {
        transform-box: fill-box;
        transform-origin: center;

        animation: starGlow 1.5s ease-in-out infinite;
    }


    @keyframes starGlow {

        0%,
        100% {
            opacity: 0.7;
            filter: drop-shadow(0 0 3px #ffd54a);
            transform: scale(0.95);
        }

        50% {
            opacity: 1;
            filter: drop-shadow(0 0 15px #ffd54a);
            transform: scale(1.08);
        }
    }


    /* 🎄 Baum leicht schwingen */
    .tree {
        transform-box: fill-box;
        transform-origin: center bottom;

        animation: treeMove 4s ease-in-out infinite;
    }


    @keyframes treeMove {

        0%,
        100% {
            transform: rotate(-1deg);
        }

        50% {
            transform: rotate(1deg);
        }
    }


    /* 💡 Weihnachtslichter */
    .lights circle {
        animation: lights 1.5s ease-in-out infinite alternate;
    }


    .lights circle:nth-child(2) {
        animation-delay: 0.3s;
    }

    .lights circle:nth-child(3) {
        animation-delay: 0.6s;
    }

    .lights circle:nth-child(4) {
        animation-delay: 0.9s;
    }

    .lights circle:nth-child(5) {
        animation-delay: 1.2s;
    }

    .lights circle:nth-child(6) {
        animation-delay: 0.2s;
    }

    .lights circle:nth-child(7) {
        animation-delay: 0.5s;
    }

    .lights circle:nth-child(8) {
        animation-delay: 0.8s;
    }

    .lights circle:nth-child(9) {
        animation-delay: 1.1s;
    }


    @keyframes lights {

        from {
            opacity: 0.3;
            filter: drop-shadow(0 0 2px currentColor);
        }

        to {
            opacity: 1;
            filter: drop-shadow(0 0 12px currentColor);
        }
    }


    /* ❄️ Schnee */
    .snow circle {
        fill: white;

        animation:
            snowfall 4s linear infinite;
    }


    .snow circle:nth-child(2) {
        animation-delay: 0.5s;
    }

    .snow circle:nth-child(3) {
        animation-delay: 1s;
    }

    .snow circle:nth-child(4) {
        animation-delay: 1.5s;
    }

    .snow circle:nth-child(5) {
        animation-delay: 2s;
    }

    .snow circle:nth-child(6) {
        animation-delay: 2.5s;
    }


    @keyframes snowfall {

        from {
            transform: translateY(-30px);
            opacity: 0;
        }

        20% {
            opacity: 1;
        }

        to {
            transform: translateY(330px);
            opacity: 0;
        }
    }

</style>

🎁 Was ist animiert?

  • ⭐ Stern: pulsiert und leuchtet
  • 💡 Lichter: blinken nacheinander
  • 🎄 Baum: bewegt sich ganz leicht
  • ❄️ Schnee: fällt über den Baum
  • 🌙 Hintergrund: enthält Mond und kleine Sterne

Das Ganze funktioniert ohne JavaScript und ohne externe Dateien.

Demo

Der Code läuft abgeschottet in deinem Browser – ohne Zugriff auf dein Konto und ohne etwas aus dem Netz nachzuladen.

Eigener Reiter Ausprobieren
Bewertung
5,0 (1 Stimmen)
Gefällt mir
1
Aufrufe
21

Melde dich an, um zu bewerten, zu liken und zu kommentieren.

Im Forum verlinken

Diesen Code in einen Forumbeitrag oder Kommentar einfügen – daraus wird eine hervorgehobene Verlinkung auf diesen Codeschnipsel.

[[snippet:animiertes-inline-svg-weihnachtsedition|Animiertes Inline-SVG – Weihnachtsedition]]

Kommentare (0)

Noch keine Kommentare.