In parent block with even block width value –
is it possible to position (or align) in the middle
this parent is a child with an odd width value?
For example, take a parent with a width of 10 pixels and a child with a width of 1 pixel.
Is it possible to position the child in the middle of such a parent?
>Solution :
Yes, This can be done using translateX. The function takes float values.
.parent{
width:10px;
height:10px;
background:black;
}
.child{
width:1px;
height:10px;
background:red;
transform:translateX(4.5px);
}
<div class="parent">
<div class="child">
</div>
</div>