weird border-radius behavior
i have created card in vite-react and i dont see something that have caused this issue,
and the issue is that so i have image that take all of the size of the card and for some reason at thhe edges of the card, the card background is slightly visible like 0.0001px.
like between the img's edge and the card's edge the is small gap, which i cant find the cause.
Here card file:
11 Replies
Here is my card css file:
hope you can see it
I'm currently trying to get an example of your code up on codepen but it's not looking right
I was going to try the suggestion mentioned here: https://css-tricks.com/forums/topic/border-radius-ugliness/
fooman
CSS-Tricks
[Solved] Border Radius Ugliness - CSS-Tricks
I'm sure this is common and a dumb mistake on my part, but does anyone know why the rounded radius on the corner has a gross light line on the very edge?
feel free to play around with this
https://codepen.io/Chris-Rowe/pen/rNEpQPz
I had to change all of your
className
to basic html with double quote values so you can't copy/paste back into react
wasn't sure why you were using the img tag with an empty source. You can just put the linear gradient right on the cardThe code (note I make the hover content element have a border radius - 1px)
The result (still not perfect, but cleaner looking than before):
well it seems like if i just used real image, it would solve everything...
also the solution from the forum was only partially solution, because when you move to mobile view, well let's say it is getting even worse.
(i updated my code, sorry i wasn't explaining properly...)
and your solution is nice but in case you only want the "img" to be only part of height, then you can't really use it as background
well i still trying to understand what made this issue to appear, but anyway i want to thank you for you help.
the term that I've heard used for this over the years is "border-radius bleed". It's an issue in all browsers. Here's the 13 year old Firefox bug as an example: https://bugzilla.mozilla.org/show_bug.cgi?id=664154
I remember there being a nice long stack overflow post about this but I can't find it right now. This is the best I can find for solutions right now: https://dev.to/rashidshamloo/css-fixing-background-color-bleed-in-rounded-corners-2kh4
although the most obvious solution that I came a cross at one point was just using a slightly different
border-radius
on the child element to cover up the issue
just remembered I also worked around this at one point by using a clip-path: inset(0 round 12px);
on the parent so that both the parent and child element got rounded in one pass.If you make the img slightly larger than its container , remove its border radius , the overflow hidden on the parent will clip anything outside its padding-box. Or use a bg image ? Depending on if img is decorative or necessary context. I haven’t looked closely at the code but I see you’re using grid, if the element is stretching it might throw off border radius
If it is img then this issue disappears, the problem appears when you try to do it with div or something like that, and i didn't had image so i thought of using for now a colored div, and then that issue appeared
Interesting solution
Can you throw your code into a codepen ?
well i tried to make it as fast as i can
https://codepen.io/jeluxe/pen/zYVpyee?editors=1100