Skip to content

Instantly share code, notes, and snippets.

@raoulduke
Created February 4, 2021 01:59
Show Gist options
  • Save raoulduke/833e408e8f787bb3d89ed648dab3177a to your computer and use it in GitHub Desktop.
Save raoulduke/833e408e8f787bb3d89ed648dab3177a to your computer and use it in GitHub Desktop.
HTML/CSS/JS Lamp Pull Chain
#light-switch {
position: fixed;
top: -1.5em;
right: 1em;
text-align: center;
cursor: pointer;
z-index: 1021;
}
#light-switch div.rounded-circle {
width: 0.3em;
height: 0.8em;
border: 2px dashed white;
margin: 0 auto;
}
#light-switch div.knob {
color: #fac403;
font-size: 0.6em;
font-family: sans-serif;
}
#light-switch div.knob span {
font-size: 0.8em;
position: relative;
bottom: 2px;
}
.pull-down {
animation: PullCord 0.6s linear;
}
@keyframes PullCord {
0%, 100% {
top: -1.5em;
}
50% {
top: 0;
}
}
<div id="light-switch">
<div class="rounded-circle"></div>
<div class="rounded-circle"></div>
<div class="rounded-circle"></div>
<div class="rounded-circle"></div>
<div class="knob"><span>{</span>II<span>}</span></div>
</div>
$('#light-switch').on('click', function() {
$(this).addClass('pull-down');
}).on('webkitAnimationEnd oanimationend msAnimationEnd animationend', function() {
$(this).removeClass('pull-down');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment