简体   繁体   English

使用overflow:hidden在div父级内显示一个弹出窗口

[英]Display a popover inside a div parent with overflow:hidden

I'm writing in angularJS and I couldn't find a comfortable solution for this issue- I have a div element with overflow: hidden property (since i'm using internal scrollbar) and inside that div I have a dropdown menu, triggered by a button click. 我正在写angularJS,我找不到一个舒适的解决方案来解决这个问题 - 我有一个带overflow: hiddendiv元素overflow: hidden属性(因为我使用的是内部滚动条)而在div里面我有一个dropdown菜单,由按一下按钮。 unfortunately, the dropdown in partially hidden (since it is exceeding the borders of its div parent. 不幸的是,在dropdown中部分隐藏(因为它超出其边界div父。

The best solution i've found so far is to add the popover dynamically to the body and calculate its position for every button click, but it is a bit complicated since i'm also using a scroller... 到目前为止我发现的最好的解决方案是将弹出窗口动态添加到主体并计算每个按钮单击的位置,但它有点复杂,因为我也使用滚动条...

Any help would be appreciated. 任何帮助,将不胜感激。 Thanks! 谢谢! Tammy 塔米

Normally you shouldn't be able to do it without either removing overflow: hidden; 通常你不应该没有删除overflow: hidden; property, or use absolute positions for your div and dropdown menu, which can be a bit tricky (make some search, there is a lot of topics on Stackoverflow). 属性,或使用div和下拉菜单的absolute位置,这可能有点棘手(进行一些搜索,Stackoverflow上有很多主题)。

But you can achieve it with position: fixed; 但你可以用position: fixed;来实现它position: fixed; , knowing that it will depend on the browser ; ,知道它将取决于浏览器; see a working example : http://jsfiddle.net/Nf7u4/ 看一个有效的例子: http//jsfiddle.net/Nf7u4/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM