What i want to get is the following image.
There are two divs. The inner div is at the center of the outer div, and text box1
is at the center of inner div.
The css code can't achieve the target.
div.father {
align-items: center;
border: 1px solid black;
display: flex;
height: 300px;
justify-content: center;
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
width: 300px;
}
div.son {
border: 1px solid black;
height: 100px;
width: 100px;
}
<div class="father">
<div class="son">box1</div>
</div>
How to put the box1
at the center of div.son?