I am struggling to create a hamburger menu icon and align it using flexbox. Unfortunately, the icon is not aligning properly as it is going beyond the menu and the browser screen with an odd top indent.
Below is the code I have written:
* {
margin: 0;
padding: 0;
}
input {
display: none;
}
.wrapper {
display: flex;
align-items: center;
justify-content: flex-end;
position: relative;
width: 100%;
height: 100px;
background: lightblue;
}
span {
position: absolute;
z-index: 1;
width: 70px;
height: 5px;
background: #000;
display: block;
}
span:nth-child(1) {
top: 0px;
}
span:nth-child(2) {
top: 30px;
}
span:nth-child(3) {
top: 60px;
}
label {
background: red;
position: relative;
display: block;
}
<div class="wrapper">
<input type="checkbox" id="click">
<label for="click">
<span></span>
<span></span>
<span></span>
</label>
</div>
I also noticed that the label element does not seem to be recognizing its child elements. Typically, a parent element with
position: relative/fixed/absolute
should recognize its children with position: absolute
.
What could I be missing here?