I am trying to create a dropdown in CSS. I have finished writing the CSS code, but the dropdown pushes all my other objects on the screen down and that is not what I want. Instead, I want to show the dropdown in front of the objects instead at the top "which would end up pushing then down".
<div class="drop-down-container">
<h1>Recommended</h1>
<div class="dropdown-content-background">
<div class="dropdown-contents">
<div class="dropdown-content">
<i class="material-icons">videocam</i>
<span>Create</span>
</div>
<div class="dropdown-content">
<i class="material-icons">settings</i>
<span>Settings</span>
</div>
<div class="dropdown-content">
<i class="material-icons">person</i>
<span>Switch Account</span>
</div>
</div>
</div>
</div>
.drop-down-container{
display: flex;
align-items: center;
justify-content: space-between;
}
.dropdown-content{
display: flex;
align-items: center;
padding: 5px;
}
.dropdown-content-background{
background-color: rgb(85, 85, 85);
padding: 15px;
z-index: 2;
border-radius: 4px;
}
.dropdown-content i {
color: white;
margin-right: 5px;
}
.dropdown-content span {
color: white;
margin-left: 5px;
}
What is the best way to fix this?
