Skip to content

Instantly share code, notes, and snippets.

@domske
Last active January 30, 2026 17:22
Show Gist options
  • Select an option

  • Save domske/b66047671c780a238b51c51ffde8d3a0 to your computer and use it in GitHub Desktop.

Select an option

Save domske/b66047671c780a238b51c51ffde8d3a0 to your computer and use it in GitHub Desktop.
Bugfix (Workaround) for Safari (iOS): Border radius with overflow hidden does not work as expected.

There is a bug in Safari when using border-radius and overflow: hidden. Especially when applying transform to a child. In this case, overflow: hidden does not always work. The child ignores the border radius and overflows. It's a very old bug. And sadly it seems that it will never be fixed. Anyway, we can't wait for it.

There are some workaround. We need to place the element with the overflow attribute into a stacking context. I've tested the following workarounds on the latest version of iOS (14.4). You can choose what you want. But you should search the web for the particular attribute. (e.g. will-change should be rarely used. See docs)

Use this on the element with overflow: hidden and border-radius:

z-index: 0;
/* Or another value. */
/* The position may need to be set to e.g. relative or absolute. */

or

transform: translateZ(0);
/* Or translate3d(0, 0, 0) or other values. */

or

mask-image: radial-gradient(white, black);
/* Maybe: -webkit-mask-image: -webkit-radial-gradient(white, black); */

or

will-change: transform;
/* Read the docs first. Apparently it should be used carefully. */

Let me know if this fixed your problem or not. Personally, I use transform or z-index. These are probably the most harmless properties. But feel free to post your opinion and other great solutions.

@mosuzi

mosuzi commented Dec 5, 2022

Copy link
Copy Markdown

Unfortunately, neither those above worked for me :(

@fdambrosio

Copy link
Copy Markdown

good, it works to fix on ios 16 !

@jowc

jowc commented Jan 22, 2023

Copy link
Copy Markdown

Thanks. The z-index worked for me. :)

@cesswhite

Copy link
Copy Markdown

Thank you, two solutions work for me in CSS:
1.- mask-image: radial-gradient(white, black);
2.- will-change: transform;

In UnoCSS/TailwindCSS this class work for me:
will-change-transform

@alexhartan

Copy link
Copy Markdown

You are the man! This fix just solved a bunch of headaches for me

@SebHex

SebHex commented Apr 2, 2023

Copy link
Copy Markdown

Using the Tailwind CSS class transform-gpu worked for me

This is similar to using the following CSS:

transform: translate3d(0, 0, 0);

@dsajlovic

Copy link
Copy Markdown

April 2023 still with the same problem, ONLY in Safari -.-
Thank you for posting workaround :)

@minhoyooDEV

Copy link
Copy Markdown

life saver

@Frederick-88

Copy link
Copy Markdown

transform: translateZ(0); works for me in 2023 - thanks a lot!

@btlm

btlm commented Apr 20, 2023

Copy link
Copy Markdown

z-index: 0; works as charm

@kaiwen-wang

kaiwen-wang commented May 15, 2023

Copy link
Copy Markdown

confirming tailwind will-change-transform works

@VolodymyrShtef

Copy link
Copy Markdown

Thanks, z-index did the job

@alexfranco90

Copy link
Copy Markdown

Thanks, both z-index: 0; and transform: translateZ(0); works for me. In my case will-change: transform works too but i was trying to find an alternative.

@MartinMalinda

Copy link
Copy Markdown

Thanks!

@hieuthien

Copy link
Copy Markdown

Thanks you, all thing works with my CSS =]]

@wojciak

wojciak commented Nov 20, 2023

Copy link
Copy Markdown

❤️

@NeroTesalo

Copy link
Copy Markdown

I love you for this! Solution 2: transform: translateZ(0) save my life free from this awful bug

@sohammondal

Copy link
Copy Markdown

Awesome!! transform: translateZ(0); works for me. ❤️

@PinkiNice

Copy link
Copy Markdown

🫡🫡🫡🫡🫡🫡🫡🫡

@seamlink-aalves

Copy link
Copy Markdown

transform: translateZ(0); did it for me. Thanks

@edwardhorsford

Copy link
Copy Markdown

Many thanks, I think this helps fix a bug for us too.

@Hammaad-M

Copy link
Copy Markdown

z-index: 0 worked! Thank you!

@MohammedMMC

MohammedMMC commented Jan 13, 2026

Copy link
Copy Markdown

Thanks, Worked for me.
Apple still did not fix it XD

@nicolascrab

Copy link
Copy Markdown

transform: translateZ(0); works for me as well. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment