The text center is located in the center of the div, for example, when showing code.
.Absolute-Center { display: table-cell; width: 100px; height: 100px; border:1px solid red; text-align:center; vertical-align:middle; }
<div class="Absolute-Center"> <p>center</p> </div>
Now add the line position:absolute; in css .Absolute-Center .
.Absolute-Center { position:absolute; display: table-cell; width: 100px; height: 100px; border:1px solid red; text-align:center; vertical-align:middle; }
<div class="Absolute-Center"> <p>center</p> </div>
The center text was no longer in the center of the div, why position:absolute; can lead to this?
source share