Menu

A Full-Page Overlay That Only Covers a Card? Check the Parent for transform
📰

A Full-Page Overlay That Only Covers a Card? Check the Parent for transform

DEV Community: html·Pixel Recruiting LLC·about 9 hours ago
#PpkyxzVU
#devto2#devto#dev#transform#card
Reading 0:00
15s threshold

A share dialog is supposed to dim the whole page. You give the dimmed backdrop position: fixed and inset: 0 . That combination usually covers the window. Instead, the dimming sits only on one card. The rest of the page stays bright and clickable.

The overlay is not broken. It is obeying a different containing block. A parent, often one with a small transform used to lift the card, has become the reference for fixed .

The layout

A card lifts a little on hover. The share overlay is rendered inside the card, because that is where the button lives.

<section class = "card" > <h2> Quarterly report </h2> <button type = "button" > Share </button> <div class = "overlay" > <div class = "dialog" > Share this file </div> </div> </section>

Enter fullscreen mode

Exit fullscreen mode

.card : hover , .card.is-open { transform : translateY ( -8px ) ; }

.overlay { position : fixed ; inset : 0 ; background : rgb ( 0 0 0 / 0.4 ) ; }

Enter fullscreen mode

Exit fullscreen mode

When the card is open, or hovered, the…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.