<div class="bulb">
<div class="rounded1"></div>
<div class="rounded2"></div>
<div class="filament1">
</div>
<div class="filament2"></div>
<div class="base">
<div class="cable"></div>
</div>
</div>
* {
margin: 0;
}
body {
background: radial-gradient(#444, #222);
display: flex;
flex-direction: column;
width: 100%;
height: 100vh;
align-items: center;
justify-content: center;
transition:all .2s;
}
.bulb {
cursor: pointer;
width: 10vw;
height: 10vw;
background: #666;
border-radius: 50%;
position: relative;
transition: all 0.2s;
}
.bulb:active {
transform: translateY(1vw);
}
.bulb::after {
content: "";
width: 2vw;
height: 2vw;
bottom: 1.5vw;
right: 1.5vw;
position: absolute;
background: transparent;
border-radius: 0 0 5vw;
border-right: 1vw solid rgba(255, 255, 255, 0.1);
border-bottom: 1vw solid rgba(255, 255, 255, 0.1);
}
.base {
position: absolute;
width: 4vw;
height: 3.5vw;
background: #666;
top: -5vw;
left: 50%;
transform: translateX(-50%);
border-radius: 1vw 1vw 0 0;
z-index: 2;
}
.base::before,
.base::after {
content: "";
position: absolute;
width: 4.5vw;
height: 0.5vw;
background: #222;
border-radius: 0.5vw;
left: -0.25vw;
}
.base::before {
top: 1vw;
}
.base::after {
top: 2vw;
}
.rounded1,
.rounded2 {
position: absolute;
width: 3vw;
height: 3vw;
top: -2vw;
border-bottom-right-radius: 3vw;
background: transparent;
box-shadow: 2vw 2vw 0 1vw #666;
z-index: 1;
transition: all 0.2s;
}
.rounded1 {
left: 0.5vw;
transform: rotate(-25deg);
}
.rounded2 {
right: 0.5vw;
transform: rotate(115deg);
}
.cable {
background: #666;
width: 2vw;
position: absolute;
height: 0.5vw;
top: -0.5vw;
left: 1vw;
border-radius: 0.2vw 0.2vw 0 0;
}
.cable::before {
content: "";
background: #222;
width: 0.5vw;
position: absolute;
bottom: 0.5vw;
left: 50%;
transform: translateX(-50%);
height: 50vh;
}
.filament1, .filament2{
position: absolute;
background: #888;
width: 4.5vw;
height: 0.2vw;
top: -0.5vw;
border-radius: 0.5vw;
z-index: 1;
transition: all 0.2s;
}
.filament1 {
left: 2vw;
transform: rotate(-75deg);
}
.filament2 {
right: 2vw;
transform: rotate(75deg);
}
/* switch light on */
.light-body {
background: radial-gradient(#f6e58d, #f9ca24);
}
.light-bulb {
background: #f9ca24;
}
.light-rounded {
box-shadow: 2vw 2vw 0 1vw #f9ca24;
}
.dark-filament {
background: #222;
}
let body = document.querySelector("body"),
bulb = document.querySelector(".bulb"),
rounded1 = document.querySelector(".rounded1"),
rounded2 = document.querySelector(".rounded2"),
filament1 = document.querySelector(".filament1"),
filament2 = document.querySelector(".filament2");
bulb.addEventListener("click", function () {
body.classList.toggle("light-body");
bulb.classList.toggle("light-bulb");
rounded1.classList.toggle("light-rounded");
rounded2.classList.toggle("light-rounded");
filament1.classList.toggle("dark-filament");
filament2.classList.toggle("dark-filament");
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.