Skip to content

Instantly share code, notes, and snippets.

@camipaixao
Created May 4, 2020 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camipaixao/6b5fe47ddedca0beffc3c5091005b635 to your computer and use it in GitHub Desktop.
Save camipaixao/6b5fe47ddedca0beffc3c5091005b635 to your computer and use it in GitHub Desktop.
Efeito para menu hambúrguer
<body>
<input id="menu-hamburguer" type="checkbox">
<label for="menu-hamburguer">
<div class="menu">
<span class="hamburguer"></span>
</div>
</label>
</body>
*, *: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