The following code has used margin-left:auto, why is it still unable to be centered? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:24:57
Original
1605 people have browsed it


Reply to discussion (solution)

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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template