Street light effect in CSS by Nitin Kumar Output View Horizontal Vertical HTML CSS JS Tidy HTML CSS JS Tidy :root { --pole-dark: #1e2635; --pole-light: #233451; --sewer-dark: #3a392f; --sewer-light: #4a4a3d; --ground-light: #83744b; --ground-dark: #6d5f45; } body { margin: 0; padding: 0; width: 100vw; height: 100vh; overflow: hidden; display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg, #17175f, #ffd844); } .content { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; } .buildings { width: 100vw; height: 100vh; background: linear-gradient(180deg, #021023, #222329); clip-path: polygon(0% 41%, 2% 9%, 57% 32%, 32% 42%, 33% 40%, 29% 20%, 46% 16%, 63% 39%, 59% 39%, 61% 42%, 68% 45%, 70% 37%, 92% 27%, 92% 41%, 100% 40%, 100% 100%, 0% 100%); display: flex; align-items: center; justify-content: center; } .window { background: linear-gradient(88deg, #fff0 0 calc(50% - 0.2vw), #111 calc((50% - 0.2vw) + 1px) calc(50% + 0.2vw), #fff0 calc((50% + 0.2vw) + 1px) 100%), repeating-linear-gradient(182deg, #fff0 0 calc(30% - 0.2vw), #111 calc((30% - 0.2vw) + 1px) calc(30% + 0.2vw), #fff0 calc((30% + 0.2vw) + 1px) 37%), #e7d09a; width: 5vmin; height: 7vmin; position: absolute; left: 5vw; transform: scale(0.8); margin-top: 3vmin; clip-path: polygon(0 0, 100% 0, 85% 100%, 10% 100%); } .window:nth-child(2) { left: 16vw; filter: blur(1px); margin-top: 3.25vmin; } .window:nth-child(3) { left: 12vw; margin-top: -26vmin; filter: blur(1px); clip-path: polygon(5% 0%, 97% 1%, 85% 65%, 10% 63%); } .window:nth-child(4) { right: 12vw; margin-top: -4vmin; filter: blur(1px); left: inherit; } .window:nth-child(5) { right: 22vw; margin-top: -4vmin; left: inherit; transform: scale(0.85) rotateY(180deg); } .window:nth-child(6) { right: 17vw; margin-top: -4vmin; filter: blur(1px); left: inherit; transform: scale(0.85); } .window:nth-child(7) { right: 55vw; filter: blur(1px); margin-top: -4vmin; left: inherit; transform: scale(0.75); } .ground { background: #292828de; position: absolute; width: 150vw; height: 26vh; bottom: 0; fliter: blur(4); display: flex; align-items: center; justify-content: center; opacity: 0.5; } .streetlamp { width: 70px; height: 75vh; position: absolute; top: 25vh; margin-left: 5vmin; max-width: 80px; min-width: 80px; filter: blur(1px); } .base { bottom: 0; right: 0; position: absolute; width: 91%; height: 24%; background: linear-gradient(-94deg, var(--pole-dark) 0 23%, #fff0 calc(23% + 1px) 100%), linear-gradient(-1deg, var(--pole-dark) 0 3.65%, #fff0 calc(1.65% + 1px) 100%), linear-gradient(85deg, var(--pole-dark) 0 58%, var(--pole-light) calc(58% + 1px) 100%); border-radius: 2px; clip-path: polygon(5% 10, 76% 10, 99% 99%, 10, 99%); z-index: 1; } .basetop { background: #1e2634; filter: blur(3px); width: 75%; height: 3%; position: absolute; bottom: 24%; left: 16%; border-radius: 2px; z-index: 2; transform: rotate(-0.5deg); } .pole { position: absolute; width: 25%; height: 56.5%; background: linear-gradient(-1deg, var(--pole-dark) 0 1.65%, #fff0 calc(1.65% + 1px) 100%), linear-gradient(-91deg, var(--pole-dark) 0 35%, #fff0 calc(35% + 1px) 100%), linear-gradient(89.5deg, var(--pole-dark) 0 40%, var(--pole-light) calc(40% + 1px) 100%); bottom: 26.25%; left: 45%; clip-path: polygon(17% 0, 60% 0, 95% 99%, 0% 99%); z-index: 1; } .poletop { width: 20%; height: 1.5%; background: var(--pole-dark); position: absolute; bottom: 82%; left: 44%; z-index: 1; clip-path: polygon(0% 0, 100% 0, 95% 65%, 10% 72%); } .head { position: absolute; width: 100%; height: 100px; bottom: 83%; z-index: 1; } .head .top { background: conic-gradient(from 131deg at 55% 0, var(--pole-light) 0 12%, var(--pole-dark) 13% 29.5%, #fff0 0 100%); width: 100%; height: 30%; top: 20%; position: absolute; transform: rotate(-3deg); } .head .bot { width: 75%; height: 5%; background: linear-gradient(45deg, #fff0 12%, var(--pole-dark) 0 65%, #fff0 0 100%), linear-gradient(-50deg, #fff0 8%, var(--pole-dark) 0 65%, #fff0 0 100%); left: 17%; position: absolute; bottom: 1%; transform: rotate(-3deg); } .glass { background: linear-gradient(-79deg, #fff0 0 12%, var(--pole-dark) 13% 16%, #fff0 17% 100%), conic-gradient(from -46deg at 53% 200%, #fff0 0 13%, var(--pole-dark) 13.2% 14%, #fff0 14.2% 100%), linear-gradient(70deg, #fff0 0 21%, var(--pole-dark) 22% 25%, #fff0 26% 100%), radial-gradient(circle at 37% 250%, #fff0 0 73%, #e4ce8b 75% 100%), radial-gradient(circle at 37% 300%, #fff0 0 73%, #e4ce8b 75% 100%), conic-gradient(from -46deg at 53% 200%, #fff0 0 7%, #f5f3b0 0 13%, var(--pole-dark) 13.2% 14%, #fff0 14.2% 100%), linear-gradient(-79deg, #fff0 0 12%, var(--pole-dark) 13% 16%, #ffe5ad 17% 50%, #fff0 17% 100%); background-repeat: no-repeat; background-size: 100% 100%, 100% 100%, 100% 100%, 33% 42%, 50% 35%, 100% 100%; background-position: 0 0, 0 0, 0 0, 90% 0, 20% 0, 0 0; width: 100%; height: 45%; top: 50%; position: absolute; transform: rotate(-3deg); opacity: 0.5; } .light { background: linear-gradient(180deg, #dac47080, #dac47020 90%, #fff0 100%); width: 650px; height: 64vh; position: absolute; left: -274px; bottom: 1.5%; clip-path: polygon(43% 1%, 53% 0.35%, 100% 100%, 0 100%); opacity: 0; } .ground-light { background: #dac47080; width: 650px; left: -275px; position: absolute; bottom: -28px; height: 80px; border-radius: 100%; filter: blur(4px); z-index: 0; opacity: 0; } .top:before { content: ""; position: absolute; background: var(--pole-light); width: 8px; height: 12px; border-radius: 100%; left: 48%; top: -40%; border: 3px solid var(--pole-dark); border-left-width: 0; } .top:after { content: ""; position: absolute; background: var(--pole-dark); width: 4px; height: 12px; border-radius: 100%; left: 52%; top: -70%; } #btn { display: none; } label[for=btn] { position: absolute; width: 80%; height: 55%; z-index: 5; top: 45%; left: 11%; border-radius: 50% 50% 100% 150%; cursor: pointer; } #btn:checked + .content .light, #btn:checked + .content .ground, #btn:checked + .content .ground-light, #btn:checked + .content .head .glass { animation: turn-on 3s ease 0s 1; opacity: 1; } @keyframes turn-on { 0%, 10%, 25% { opacity: 0; } 5%, 15%, 35%, 100% { opacity: 1; } } @media screen and (orientation:landscape) and (max-width: 767px) { .light { bottom: 11%; } .ground-light { bottom: -9px; } } HTML CSS JS Tidy >_Console Clear Console >_Console File Setting HTML Code Playground Setting Title Description Street light effect in CSS, with building and street light on-off feature. Catagory CSS Tags Effect Resource Add External Stylesheets and Script