~/sohan/ghostty
[SYS]sohanscript v2026.1 initialized
[INFO]stack: ts · react · next · trpc
[INFO]location: dhaka, bangladesh
[STAT]STATUS: OPEN FOR WORK
Indexing assets0%
○ waitingmeasuring...
~
Connection
Latency: <1ms
Kernel
Aura Engine v4.2
Skip to main content
1fb69f117379804f644a
·1 min read

Overriding Parent's Overflow Hidden Property for Specific Children

css
tailwindcss
3ef4f885272bc6323209

Sohan R. Emon

Developer, Learner, Tech Enthusiast

Have you ever encountered a situation where a child element within a parent with overflow: hidden gets hidden when it goes beyond its parent's boundaries? Even using z-index doesn't seem to work in such cases. Here's a simple solution:

The Problem

Suppose you have a parent element with overflow: hidden, and you want to prevent a specific child element (like a button) from getting hidden, even if it becomes larger or you want to translate it.

Parent:

jsx
<div class='overflow-hidden'>...</div>

Child (e.g., Button):

jsx
<button>...</button>

The Solution

To solve this issue, you can wrap both the parent and child within an additional container. Apply the overflow: hidden property to the inner container instead of the parent. Also, make the child element position: fixed to keep it visible when it goes beyond the parent's boundaries.

Updated Structure:

Parent:

jsx
<div class='translate-x-0 translate-y-0'>
  <div class='overflow-hidden'>...</div>
</div>

Child (e.g., Button):

jsx
<button class='fixed'>...</button>

By using this approach, you effectively override the parent's overflow: hidden property for the specific child element, allowing it to remain visible regardless of its size or positioning.

Found this useful? Share!