Parent has
rounded-2xl
, but image corners are sharp.
rounded-*
to Child
Image also has
rounded-2xl
. This works without
overflow-hidden
if the child's rounding matches the parent's intended visual effect.
Gotcha Explanation (Alternative Solution):
Another way to handle the "child overflowing parent's rounded corners" issue is to apply the rounding utility (e.g.,
rounded-lg
) directly to the child element as well. If the child element (like an image) is meant to fill the parent and share its rounded appearance, ensure its rounding matches the parent's. This can be simpler than
overflow-hidden
if you don't want to clip other potential overflowing content or if the child needs its own specific rounding that might differ slightly (e.g.,
rounded-t-lg
if only top corners need matching).