CSS Positioning inconsistent across browsers

I have this cute little svg/psedo-element positioned 12px to the left from the border of the parent element... In chrome, it looks okay, but in firefox and microsoft edge looks much farther away than i have set. Its parent has position: sticky and the pseudo-element has position:absolute I do have a css reset applied,. I also inspected to check if firefox was adding styles that weren't in my reset, but that doesn't seem to be the case... Their computed values seem correct... 64px wide, and 12px to the left as shown in the image... So I can't think of anything else to check, or maybe I'm just too tired to think codepen: https://codepen.io/bavosadev/pen/vEBQbqm
No description
13 Replies
Vinicius
ViniciusOPā€¢2w ago
You see how in Chrome, the area of the element in blue overlaps the "S"? While in firefox it doesn't... what could be the reason for that
b1mind
b1mindā€¢2w ago
do you have both a viewBox and w/h on the svg element?
Vinicius
ViniciusOPā€¢2w ago
yes
b1mind
b1mindā€¢2w ago
i'd have to see an example to debug most likely both do handle svg differently though its a pita sometimes shakes fist at FF its always FF's fault the new IE
Vinicius
ViniciusOPā€¢2w ago
if it helps, the svg is being render as background-image of the pseudo-element šŸ˜­ i'll try to remake it in codepen sorry for not have done that before hand
Vinicius
ViniciusOPā€¢2w ago
Here's the codepen... i had to hard code the svg position bcs i couldn't add as a background-image on codepen https://codepen.io/bavosadev/pen/vEBQbqm Yet, the same behavior appears in Firefox and IE
Vinicius
ViniciusOPā€¢2w ago
I tested it on Safari. SVG element is even more farther away than on Firefox or IE šŸ˜‚
No description
b1mind
b1mindā€¢2w ago
Not at my PC anymore but I'll check when I am, looks way off on edge too I'll have to look closer
Vinicius
ViniciusOPā€¢2w ago
The problem may be chrome? I bootstrapped it, and now it has the same amount of distance as firefox, IE and safari
No description
Vinicius
ViniciusOPā€¢2w ago
and they're not overlaping...
No description
Vinicius
ViniciusOPā€¢2w ago
I think i found the issue... it might be because of absolute positioning will try to directly insert the svg into the markup, instead of using a pseudo-element
capt_uhu
capt_uhuā€¢2w ago
only had a quick look but it seems that the heart of your problem is your SVG is 84x84 but the design inside it is only about 20x20. This leads to 60 some pixels of white space to the right and bottom of the icon that you are having to work around.
Vinicius
ViniciusOPā€¢2w ago
yeyy i managed to fixed šŸ™ŒšŸ» Instead of positioning it in relation to the entire header, I positioned it in relation to the "soluciona+" logo. I believe this was the problem... the header has a dynamic width (I'm using clamp) so any different calculation would move the pseudo-element it's a pseudo-element of "soluciona+" element now

Did you find this page helpful?