A Pen by Rodrigo Muniz on CodePen.
Created
July 20, 2019 20:44
-
-
Save beseidel/6132057886bccd21936bd8b382caae5e to your computer and use it in GitHub Desktop.
Panel up open/close CSS3 animated button
This file contains hidden or 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 class="btn-open-close"> | |
<span class="bar1"></span> | |
<span class="bar2"></span> | |
</div> |
This file contains hidden or 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
$('.btn-open-close').on('click', function() { | |
$('.btn-open-close').toggleClass('active') | |
}) |
This file contains hidden or 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
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
This file contains hidden or 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
@import "lesshat"; | |
@afd-blue: #1F2D39; | |
@afd-blue-light: lighten(@afd-blue, 60%); | |
@afd-yellow: #FFD390; | |
.btn-open-close { | |
display: block; | |
cursor: pointer; | |
background-color: @afd-blue; | |
height: 46px; | |
width: 46px; | |
position: absolute; | |
left: 0; | |
right: 0; | |
top: 0; | |
bottom: 0; | |
margin: auto; | |
border-radius: 50%; | |
border: 1px solid #0E161A; | |
border-width: 1px 0 1px 1px; | |
box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.2), inset 0 1px 0 0 rgba(255, 255, 255, .2); | |
span { | |
top: 22px; | |
left: 12px; | |
position: absolute; | |
display: block; | |
width: 22px; | |
height: 4px; | |
background: @afd-blue-light; | |
border-radius: 3px; | |
transition: all 1s ease-in-out; | |
} | |
.bar1 { | |
transform: scale(.8,.8) translateX(-6px) translateY(-1px) rotate(-45deg); | |
} | |
.bar2 { | |
transform: scale(.8,.8) translateX(7px) translateY(-1px) rotate(45deg); | |
} | |
&.active { | |
.bar1 { | |
transform: scale(1,1) translateX(0px) translateY(-1px) rotate(45deg); | |
} | |
.bar2 { | |
transform: scale(1,1) translateX(0px) translateY(-1px) rotate(-45deg); | |
} | |
} | |
&:hover { | |
span { | |
background-color: @afd-yellow; | |
transition: all .4s; | |
} | |
} | |
&:active { | |
transform: scale(.95,.95); | |
transition: all .2s; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment