Skip to content
Advertisement

Why is my card overlapping the fixed nav when I hover it?

I have a problem when I hover my article with class="card" name inside my div class="container", it looks like the article overlaps the nav. How do I fix this without removing my transform scale in .card:hover? I want to make it without overlapping with the nav when I hover over it.

JavaScript
JavaScript
JavaScript

If anything is missing from the snippet, you can check my jsfiddle here

Advertisement

Answer

What you’re experiencing is something referred to as The Stacking Context which, if you think about it from a top-down perspective, is how elements are rendered in the browser. To solve this, you can set the parent element — in this case the header-container — to position: relative; and give it a z-index of 1 to override the default of 0. That will elevate it above the card which is using the default of 0 even when hovered.

Here’s another good explanation for it as well: https://www.joshwcomeau.com/css/stacking-contexts/

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement