Created
February 4, 2021 01:59
-
-
Save raoulduke/833e408e8f787bb3d89ed648dab3177a to your computer and use it in GitHub Desktop.
HTML/CSS/JS Lamp Pull Chain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#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