CSS网格下拉列表被切断
我目前正在面临CSS网格和截止菜单的问题。 我已经创建了一个简单的下拉列表 - <代码>位置:相对和菜单本身,位置:绝对
。
通常,这不是一个问题,但是当在CSS网格中使用时,下拉列表不会重叠和截止。
浅灰色的东西应该是下拉菜单。通常,这应该与黑色区域重叠。
我的布局基于CSS网格,我的网格有一个网格区域定义
.container {
display: grid;
grid-template-columns: 1fr 1fr 1fr 0.5fr 1fr;
grid-template-rows: 103px 1fr 1fr 1fr 1fr 0.5fr;
gap: 0px 0px;
grid-auto-flow: row;
grid-template-areas:
'header header header header header'
'stage stage stage selector selector'
'stage stage stage selector selector'
'stage stage stage selector selector'
'stage stage stage selector selector'
'panel panel panel selector selector'
'footer footer footer footer footer';
width: 100%;
height: 100%;
}
该下拉列表在面板区域内放置。
.panel {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 100%;
width: 100%;
}
下拉列表CSS
.dropdown {
position: relative;
display: inline-block;
min-width: 180px;
padding: 10px 0;
overflow: visible;
z-index: auto;
}
.dropdown-content {
z-index: 1;
position: absolute;
transition: all 0.5s ease;
left: 0;
top: 20px;
display: bock;
}
和简化的下拉列表html
<div class="dropdown">
<button>
... texts and icon ...
</button>
<ul class="dropdown-content">
<li>Entry 1</li>
<li>Entry 2</li>
</ul>
</div>
我真的不知道我在这里做错了什么。 任何帮助或想法都非常感谢。
I'm currently facing an issue with CSS grid and a dropdown menu that is cut-off.
I've created a simple dropdown-wrapper with position: relative
and the menu itself with position: absolute
.
Normally this shouldn't be a prob, but when used in CSS-grid the dropdown is not overlapping and cut-off instead.
the light greyish thing should be the dropdown menu. This should normally overlap the blackish area.
My layout is based on css grid and I have a grid with grid areas defined
.container {
display: grid;
grid-template-columns: 1fr 1fr 1fr 0.5fr 1fr;
grid-template-rows: 103px 1fr 1fr 1fr 1fr 0.5fr;
gap: 0px 0px;
grid-auto-flow: row;
grid-template-areas:
'header header header header header'
'stage stage stage selector selector'
'stage stage stage selector selector'
'stage stage stage selector selector'
'stage stage stage selector selector'
'panel panel panel selector selector'
'footer footer footer footer footer';
width: 100%;
height: 100%;
}
The dropdown is placed inside the panel area.
.panel {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 100%;
width: 100%;
}
The dropdowns CSS
.dropdown {
position: relative;
display: inline-block;
min-width: 180px;
padding: 10px 0;
overflow: visible;
z-index: auto;
}
.dropdown-content {
z-index: 1;
position: absolute;
transition: all 0.5s ease;
left: 0;
top: 20px;
display: bock;
}
And the simplified dropdowns html
<div class="dropdown">
<button>
... texts and icon ...
</button>
<ul class="dropdown-content">
<li>Entry 1</li>
<li>Entry 2</li>
</ul>
</div>
I don't really know what I'm doing wrong here.
Any help or ideas are really appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论