My challenge involves two squares in a container that overlap using transform: translate. I am seeking to eliminate the padding to the right of the blue square so that the container perfectly accommodates the width of the children. View the image for clarity.
Visual representation of the issue
I attempted setting the container size to 90px
, which should match the total width of the children (50px + 50px - 10px)
. However, this caused the blue box to drop to the next row. Why does this occur? I also experimented with applying padding-right: 0
but observed no changes.
.container {
width: 110px;
border: 1px solid black;
}
.box {
height: 50px;
width: 50px;
display: inline-block;
}
.one {
background: red;
}
.two {
background: blue;
transform: translate(-10px, 15%);
}
<div class="container">
<div class="box one"></div>
<div class="box two"></div>
</div>
My goal is to have no left or right padding present.