【发布时间】:2018-08-06 07:11:09
【问题描述】:
我试图在父 div 当父 div 的水平滚动可见时显示一个 100% 高度的子 div。虽然最初,它看起来很简单,但一直在努力解决。
这是标记https://codepen.io/ambarbs/pen/OwwojV
.parent {
background: grey;
height: 100px;
width: 200px;
overflow-x: auto;
overflow-y: hidden;
color: white;
/* z-index: 0; */
}
.child {
width: 400px;
}
.menu {
height: 300px;
background: orange;
z-index: 500;
}
<div class='parent'>
<div class='child'>
I want to show the orange .menu DIV on top of this DIV.
Is it possible when the horizontal scroll is visible?
</div>
<div class='menu'></div>
</div>
更新: menu 实际上是一个上下文菜单,并且应该总是显示在滚动条的顶部。
【问题讨论】:
-
你能更详细地解释你的问题吗? on-top 部分有点混乱。有时,当单词稀缺时,一张图可以帮助理解。