Gap between divs...

I made a div container with border in that div I made another div with background color. Between those 2 divs there is a tiny tiny gap. Margin: -2px; fixes it. Can anyone explain me why is this happening ? I even removed all my css that affects layout like margins or paddings, tried to set them to 0 and it didn't work. :/
34 Replies
Psyzen
PsyzenOP•3y ago
How can there be a gap between parent div and child div without margin and padding LOL
MarkBoots
MarkBoots•3y ago
Do you have other content inside that inner div? please share some more code html/css. preferably in a codepen (https://pen.new)
CodePen
...
Psyzen
PsyzenOP•3y ago
https://codepen.io/LCSNeo/pen/xxjpKME I also have the reset.css but it shouldn't affect it.
MarkBoots
MarkBoots•3y ago
can not see a gap
Psyzen
PsyzenOP•3y ago
Really ? I can clearly see it on chrome
Psyzen
PsyzenOP•3y ago
MarkBoots
MarkBoots•3y ago
not in firefox or chrome
Psyzen
PsyzenOP•3y ago
the Fudge šŸ˜„ what is going on with my chrome
MarkBoots
MarkBoots•3y ago
are you zoomed?
Psyzen
PsyzenOP•3y ago
No
MarkBoots
MarkBoots•3y ago
so not zoomed in or out? (try ctrl+0)
Psyzen
PsyzenOP•3y ago
If I zoom in to 125% the gap disappears but at 100% still exists and yes I did use ctrl+0
MarkBoots
MarkBoots•3y ago
the code is correct, so no worry about that. but what is happening with your browser ? I don't know
Psyzen
PsyzenOP•3y ago
Good question I would that the localhost apache server messing up but its not just in localhost
MarkBoots
MarkBoots•3y ago
hm, maybe someone else has an idea
Psyzen
PsyzenOP•3y ago
Hopefully
CodeNascher
CodeNascher•3y ago
whats your monitor's resolution? (both of you) i own a UHD display and i sometimes have very thin lines flashing similar to that, if i overlay some divs with the same dimensions but different colors. or if i build a 3d cube with skew and rotate. it's almost like half a pixel or less seemingly not lining up. disappears when zooming
MarkBoots
MarkBoots•3y ago
yea, pixel density could be an issue. but on 100% it are whole pixels (all the values are px or em). So default should be okay
Psyzen
PsyzenOP•3y ago
CodeNascher
CodeNascher•3y ago
hmm, is it getting better if you turn off windows' scaling?
Psyzen
PsyzenOP•3y ago
sadly it does LOL but then everything on my screen is just for ants to read šŸ˜„
CodeNascher
CodeNascher•3y ago
lol, i run my uhd at 100% so it definitely seems like a scaling/pixel density problem
Psyzen
PsyzenOP•3y ago
I can barely read it anything 100%
Psyzen
PsyzenOP•3y ago
vs
Psyzen
PsyzenOP•3y ago
125%
CodeNascher
CodeNascher•3y ago
hehe, but yeah, it's just a display error. nothing wrong with your code
Psyzen
PsyzenOP•3y ago
But.. it irritates me šŸ˜‚
CodeNascher
CodeNascher•3y ago
nothing i can do lol
MarkBoots
MarkBoots•3y ago
i think you can scale only text in "advanced scaling settings" (im on windows 11 so i can not check)
CodeNascher
CodeNascher•3y ago
yep, discord has text scaling oh, misinterpreted that you mean in windows can confirm for 10
Psyzen
PsyzenOP•3y ago
There is only custom scaling I will try that
MarkBoots
MarkBoots•3y ago
do you have Accessibility > text size?
Psyzen
PsyzenOP•3y ago
Found it. Thank you. Now to adjust it. No wonder I was going crazy multiple times thinking my code is bad.

Did you find this page helpful?