Home >Web Front-end >HTML Tutorial >The following code has used margin-left:auto, why is it still unable to be centered? _html/css_WEB-ITnose
I want to set the DIV to remain unchanged on TOP and not move down due to the increase in the height of the previous DIV, so I set position: absolute;top: 120px;
But in this case, what about automatic centering?
If you have used position:absolute;, you need to use top:50%; left:50%; for centering.
This also depends on the position of your element in the document flow. Haha, but generally Left: 50% can be centered. You can adjust the specific value yourself
If you have a width and add auto, it will be centered. No absolute positioning is needed