Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

How to use z-index to position pop-ups in front of all elements in a sheet?

December 31 (6 years ago)

Edited December 31 (6 years ago)

I'm trying to include hover-over pop-ups in my character sheet, to contain details that would otherwise clutter things up.  They appear whenever a player hovers over one of the "ankh" icons: 

   -->  

My CSS uses z-index to ensure the pop-ups appear on top of the other elements, which usually works:

    .charsheet input.sheet-hoverpopup + span + div {
        left: calc((-10%)/2);
        bottom: 20px;
        height: 190px !important;
        width: 150%;

        display: none; (changed to "block" by a :hover pseudo-class elsewhere)
        position: absolute;

        background: url("https://imgur.com/kBl8aTO.jpg");
        background-size: 100%;

        border: 3px white outset;

        z-index: 250;
    }


My problem arises when I have multiple columns of fieldset rows.  Unfortunately, it seems z-index is only able to position elements within a column --- no matter how high I set the z-index, my popups refuse to cover up elements in a previous column:

I've scoured the Internet, but I can't quite figure out the right search terms to pull up the answers I'm looking for.  Anyone have any advice or insight on how to guarantee my popups stay above the rest of my sheet?  Thanks in advance!

December 31 (6 years ago)
vÍnce
Pro
Sheet Author

Do the other elements have positioning and z-index set as well?

December 31 (6 years ago)

Yes, as far as I can tell from the topmost div elements all the way down to the inputs and spans; position is set as well for everything.  No matter how high I crank up the z-index on the popup, items in other columns continue to appear over it.

Does the type of position matter?  I.e. does position: absolute appear behind position: relative, regardless of z-index?

December 31 (6 years ago)

Edited December 31 (6 years ago)
vÍnce
Pro
Sheet Author

I'm just a hack. ;-P

but I would have a quick read here;

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Stacking_without_z-index

When the z-index property is not specified on any element, elements are stacked in the following order (from bottom to top):
The background and borders of the root element
Descendant non-positioned blocks, in order of appearance in the HTML
Descendant positioned elements, in order of appearance in the HTML

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/Adding_z-index

When no z-index property is specified, elements are rendered on the default rendering layer 0 (zero).
If several elements share the same z-index value (i.e., they are placed on the same layer), stacking rules explained in the section Stacking without z-index apply.

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context

The hierarchy of stacking contexts is a subset of the hierarchy of HTML elements, because only certain elements create stacking contexts. We can say that elements that do not create their own stacking contexts are assimilated by the parent stacking context.

You also might try applying a negative value to the elements that are floating above your hover text.


December 31 (6 years ago)

Edited December 31 (6 years ago)

Thanks, I will check that out!  From the parts you quoted, I think my original assumption was right --- because the rows in each column are isolated within their own column divs, it may not be possible for a child of one parent element to have a higher effective z-index than a child of a different parent element, since the z-sorting of the parent elements overrides whatever the children are doing.   (Okay, that sentence made more sense in my head, I admit.)

Edited to Add:  Wait, your first quote might contain the answer to my problem!  If I just remove the position declarations from the non-pop-up divs, then the positioned pop-ups should (according to that quote) appear in front of the non-positioned elements.  I'll give it a try and report back!

December 31 (6 years ago)

That did indeed fix my problem!  Thanks a ton for posting, hack or not! ;)

December 31 (6 years ago)
Coal Powered Puppet
Pro
Sheet Author

Ryan said:

That did indeed fix my problem! 

Vince does that a lot.