A Utility Class for Covering Elements

Big ol’ same to Michelle Barker here:

Here’s something I find myself needing to do again and again in CSS: completely covering one element with another. It’s the same CSS every time: the first element (the one that needs to be covered) has position: relative applied to it. The second has position: absolute and is positioned so that all four sides align to the edges of the first element.

.original-element { position: relative; }

.covering-element { position: absolute; top: … Read article “A Utility Class for Covering Elements”

The post A Utility Class for Covering Elements appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

https://css-irl.info/a-utility-class-for-covering-elements/

Creato 4y | 26 dic 2020, 16:20:44


Accedi per aggiungere un commento

Altri post in questo gruppo

Compiling CSS With Vite and Lightning CSS

Are partials the only thing keeping you writing CSS in Sass? With a little configuration, it's possible to compile partial CSS files without a Sass dependency. Ryan Trimble has the details.

<hr

3 feb 2025, 15:40:18 | CSS tricks
Keeping the page interactive while a View Transition is running

When using View Transitions you’ll notice the page becomes unresponsive to clicks while a View Transition is running

31 gen 2025, 20:30:06 | CSS tricks
Chrome 133 Goodies

Did you see the release notes for Chrome 133? It's currently in beta, but the Chrome team has been publishing a slew of new articles with pretty incredible demos that are tough to ignore. I figured

31 gen 2025, 15:50:08 | CSS tricks
The Mistakes of CSS

All of the things that the CSS Working Group would change if they had a time-traveling Delorean to go back and do things over.


30 gen 2025, 16:40:05 | CSS tricks
What on Earth is the `types` Descriptor in View Transitions?

The @view-transition at-rule has two descriptions. One is the commonly used navigation descriptor. The second is types, the lesser-known of the two, and one t

29 gen 2025, 15:10:17 | CSS tricks
Revisiting CSS Multi-Column Layout

After 20 years since Andy Clarke first published his book about Multi-Column Layout in CSS, he's back to encourage a fresh look at CSS columns for enhanced readability and design flexibility.

<

27 gen 2025, 16:50:07 | CSS tricks
Positioning Text Around Elements With CSS Offset

When it comes to positioning elements on a page, including text, there are many ways to go about it in CSS — the literal position property with corresponding inset-* prope

24 gen 2025, 16:50:19 | CSS tricks