-
Realistic Modern Pendant Lamp Animation
HTML
CSS
JavaScript
Click to interact
* { margin: 0; padding: 0; box-sizing: border-box; } body { height: 100vh; display: flex; justify-content: center; background: #0a0a0a; overflow: hidden; font-family: system-ui, -apple-system, sans-serif; } /* Hidden Checkbox for Click Interaction */ #lamp-switch { display: none; } /* UI Hint */ .hint { position: absolute; top: 20px; color: #444; font-size: 0.9rem; letter-spacing: 1px; text-transform: uppercase; transition: 0.5s; pointer-events: none; } /* Room Ambient Light */ .room-light { position: absolute; inset: 0; background: radial-gradient(circle at 50% 30%, rgba(255, 200, 100, 0.15), transparent 70%); opacity: 0; transition: opacity 0.8s ease; pointer-events: none; } /* Lamp Assembly (Handles the swing) */ .lamp-wrapper { position: relative; transform-origin: top center; animation: swing 5s ease-in-out infinite; display: flex; flex-direction: column; align-items: center; z-index: 10; cursor: pointer; } /* Braided Wire */ .wire { width: 4px; height: 25vh; /* Responsive height */ background: linear-gradient(to right, #222, #444, #222); box-shadow: inset 1px 0 2px rgba(255,255,255,0.1); } /* Modern Rounded Shade */ .shade { position: relative; width: 160px; height: 90px; background: linear-gradient(to right, #1a1a1a, #333 30%, #111 80%, #1a1a1a); border-radius: 60px 60px 0 0; box-shadow: inset 0 -5px 15px rgba(0,0,0,0.9); } /* Inner Metallic Rim */ .shade::after { content: ""; position: absolute; bottom: -6px; left: 0; width: 100%; height: 12px; background: linear-gradient(to right, #6b4c1a, #b8860b, #6b4c1a); border-radius: 50%; box-shadow: inset 0 2px 5px rgba(0,0,0,0.8), 0 5px 10px rgba(0,0,0,0.5); z-index: 2; } /* Edison Style Bulb */ .bulb { position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%); width: 45px; height: 45px; background: #333; border-radius: 50%; transition: all 0.5s ease; z-index: 1; box-shadow: inset 0 0 10px rgba(0,0,0,0.9); } /* Soft Light Beam */ .beam { position: absolute; top: calc(25vh + 90px); /* Starts right below shade */ left: 50%; transform: translateX(-50%); width: 350px; height: 75vh; background: linear-gradient(to bottom, rgba(255, 220, 120, 0.4), transparent 80%); clip-path: polygon(38% 0%, 62% 0%, 100% 100%, 0% 100%); opacity: 0; transition: opacity 0.6s ease; pointer-events: none; filter: blur(12px); } /* Dynamic Floor Reflection */ .floor { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 70vw; /* Responsive width */ height: 15vh; background: radial-gradient(ellipse at center, rgba(255, 200, 80, 0.25), transparent 60%); border-radius: 50%; opacity: 0; transition: opacity 0.8s ease; pointer-events: none; } /* ========================================= ON STATES (Triggered by hidden checkbox) ========================================= */ #lamp-switch:checked ~ .lamp-wrapper .bulb { background: #fff8d0; box-shadow: 0 0 20px #fff2a6, 0 0 50px #ffd76a, 0 0 100px #ffcf4a; animation: flicker 0.2s infinite alternate; } #lamp-switch:checked ~ .lamp-wrapper .beam { opacity: 1; } #lamp-switch:checked ~ .floor { opacity: 1; } #lamp-switch:checked ~ .room-light { opacity: 1; } #lamp-switch:checked ~ .hint { opacity: 0; } /* Smooth Swing Motion */ @keyframes swing { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } } /* Subtle Flicker for Realism */ @keyframes flicker { from { filter: brightness(100%); } to { filter: brightness(110%); } }
Live Preview