I have a dropdown menu in my header (which is always open in this example).When the menu is open, it is activating the header scroll when its open. How can I make the menu visible without activating the vertical header scrollbar? Please note that I need to have the overflow-x: hidden
set on the header because if people add a lot of elements in the header, the header horizontal scroll should not activate. The overflowing elements should just be hidden horizontally.
body{
padding: 0;
margin: 0;
}
.container{
display: flex;
flex-direction: column;
}
.header{
padding: 12px;
flex: 0 0 75px;
background: yellow;
overflow-x: hidden;
}
.content{
flex: 1 1 auto;
padding: 12px;
}
.dropdown{
position: relative;
}
.menu{
padding: 12px;
position: absolute;
background: white;
top: 100%;
left: 0;
}
ul{
list-style: none;
margin: 0;
padding: 0;
}
<div class="container">
<div class="header">
<div class="dropdown">
<button>Dropdown</button>
<div class="menu">
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
</ul>
</div>
</div>
</div>
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sequi distinctio sit asperiores tenetur dolorum ratione cupiditate, ea, quia numquam, inventore aspernatur repudiandae, sapiente recusandae dolorem. Quidem rem molestias, fugit molestiae.
</div>
</div>
For example: The stackoverflow dropdown: The dropdown menu appears over the header when open without the header having a scrollbar. I want something like this to happen: