I've encountered a surprising conundrum while working towards an answer for Align the green box with the grey box.
Is it impossible to center (without resizing) a child div against a parent div with asymmetric padding without knowing the padding amount no matter the positioning (float/absolute/static) or display (flex/grid/block/inline) or anything else?
In other words, for any value of X and any widths != 0, center child against parent so that the distance for each side from blue/red to red/white is the same.
.parent {
width: 10em;
padding-right: X;
background: red;
}
.child {
width: 4em;
height: 4em;
background: blue;
}
<div class="parent">
<div class="child">
</div>
</div>
edit: CSS only. Outer HTML OK but nothing between parent/child