Skip to content

Instantly share code, notes, and snippets.

@synecdocheNORTH
Created January 9, 2019 20:02
Show Gist options
  • Save synecdocheNORTH/8bd61be15a8d44fc177c4274603eee42 to your computer and use it in GitHub Desktop.
Save synecdocheNORTH/8bd61be15a8d44fc177c4274603eee42 to your computer and use it in GitHub Desktop.
Opening Advent Calendar Door
<h2>Click on the red door to open it</h2>
<div class="door-frame">
<div class="door"></div>
<div class="star"></div>
</div>
$('.door-frame').click(function () {
$(this).find('.door').toggleClass('open');
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
body {
text-align: center;
}
.door-frame {
position: relative;
perspective: 150px;
border: 1px solid red;
width: 100px;
height: 75px;
margin: 2em auto;
cursor: pointer;
}
.door {
border: 1px solid red;
display: block;
position: absolute;
background: red;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 1;
transform: rotateY(0deg);
transform-origin: 0;
transition-property: all;
transition-duration: 0.5s;
&.open {
transform: rotateY(-120deg);
transform-origin: 0 50% 0;
width: 15%;
}
}
$star_size: 25px;
$star_offset: 15px;
.star {
position: absolute;
width: 0;
height: 0;
border-left: $star_size solid transparent;
border-right: $star_size solid transparent;
border-bottom: ($star_size + $star_offset) solid red;
top: $star_size - $star_offset;
left: $star_size;
line-height: 0;
font-size: 0;
&:after {
content:"";
position: absolute;
width: 0;
height: 0;
border-left: $star_size solid transparent;
border-right: $star_size solid transparent;
border-top: ($star_size + $star_offset) solid red;
margin: $star_offset 0 0 -$star_size;
top: 0;
left: -$star_size;
line-height: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment