2

I am trying show "popup" windows that appear when the user hovers the cursor over a div. Everything is working fine, except when I added a scrollbar to my div. The CSS code to show the scrollbar is something like:

.scroll-menu {
   max-height: 100px;
   overflow-x: hidden;
   overflow-y: scroll;
}

Here is an image before including the .scroll-menu class, no using scrollbar

And here is an image after including the CSS class.

using scrollbar

I found this article where the author says why z-index in my scenario: http://www.satya-weblog.com/2012/01/css-z-index-not-working.html

Now, my question is: How can I solve this issue? Is there any way to get working z-index and overflow?

2
  • if possible provide us fiddle link Commented Dec 9, 2013 at 16:39
  • 1
    I would say to remove overflow-x: hidden; Commented Dec 9, 2013 at 16:40

2 Answers 2

4

This is not a z-index issue, but an overflow issue. Because you set the overflow to hidden any element visually sticking out of it's container, will be partially hidden - like in your screenshot. What you need to do is move your popup element outside of its container, the one that is set to overflow-x:hidden

so if your HTML currently looks like this:

<div class="scroll-menu">
    .... content ....
    <div class="popup"></div>
</div>

you want to change it to:

<div class="scroll-menu">
    .... content ....
</div>
<div class="popup"></div>
Sign up to request clarification or add additional context in comments.

1 Comment

yes, this is a good way to solve it. The bad news (for me) is that i am using durandarl/widget in order to show this popup (where every element in my list has a "popup" widget associated to it. I think the only way to solve my issue is add some kind of pagination to my list and forget it this "scrollbar". Your answer was very useful since now i know that i don't have any chance with overflow and z-index.
0
overflow-x: hidden;

I believe this line may be causing your issue, since you're telling the containing div to truncate anything beyond it's borders.

1 Comment

it doesn't delete overflow-x while overflow-y is set

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.