I recreated a stripped down version of the phenomenon I'm facing. So the parent has position: relative and the ::after child has position: absolute with all directional values set to zero. This would normally stretch out the child directly over the parent perfectly in my experience. Also * { margin: 0; padding: 0 } is set to be safe and make sure this isn't a margin or padding issue.
I know I can just set the child element -1px left and up... but I'm kind of curious to why this is happening if the child is stretched out directly over it's parent? Is there a way to make it work with top, right, bottom, and left set to 0?
* {
margin: 0;
padding: 0;
}
body {
padding: 5rem; /* to push div closer to center of snippet window */
}
div {
transform: scale( 5 ); /* added so displacement can be easily seen */
}
div, div::after {
display: block;
position: relative;
width: 1rem;
height: 1rem;
background-color: #eee;
border-style: solid;
border-width: 0.1rem;
border-color: #666;
border-radius: 0.25rem;
content: '';
}
div::after {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
}
<div></div>
Notice from the snippet ( In Chrome atleast ) The div's are offset from each other by about 1 px.
Picture of what I'm seeing in Chrome on desktop:
Why aren't these div's placed directly on top of each other?
