Created
May 4, 2020 17:28
-
-
Save camipaixao/6b5fe47ddedca0beffc3c5091005b635 to your computer and use it in GitHub Desktop.
Efeito para menu hambúrguer
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
<body> | |
<input id="menu-hamburguer" type="checkbox"> | |
<label for="menu-hamburguer"> | |
<div class="menu"> | |
<span class="hamburguer"></span> | |
</div> | |
</label> | |
</body> |
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
*, *:before, *:after { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
body { | |
background: pink; | |
} | |
.menu { | |
background: #fff; | |
border-radius: 50%; | |
width: 60px; | |
height: 60px; | |
position: fixed; | |
bottom: 25px; | |
right: 25px; | |
} | |
.hamburguer { | |
position: relative; | |
display: block; | |
background: #000; | |
width: 30px; | |
height: 2px; | |
top: 29px; | |
left: 15px; | |
transition: .5s ease-in-out; | |
} | |
.hamburguer:before, .hamburguer:after { | |
background: #000; | |
content: ''; | |
display: block; | |
width: 100%; | |
height: 100%; | |
position: absolute; | |
transition: .5s ease-in-out; | |
} | |
.hamburguer:before { | |
top: -10px; | |
} | |
.hamburguer:after { | |
bottom: -10px; | |
} | |
input { | |
display: none; | |
} | |
input:checked ~ label .hamburguer { | |
transform: rotate(45deg); | |
} | |
input:checked ~ label .hamburguer:before { | |
transform: rotate(90deg); | |
top: 0; | |
} | |
input:checked ~ label .hamburguer:after { | |
transform: rotate(90deg); | |
bottom: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment