Home > Web Front-end > HTML Tutorial > [Front Desk] css control DIV vertical centering_html/css_WEB-ITnose

[Front Desk] css control DIV vertical centering_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:28:37
Original
1591 people have browsed it

I just forwarded a post about vertical alignment of divs. It’s easy to understand after reading the picture

Use absolute position: absolute;
and then set top and left to 50.top:50%;left:50%;
Because at this time the browser The position shown by the green dot in the picture will be the default actual position. To center the content, set margin-left and margin-top to negative half width and half width respectively.

Anyway, the effect is achieved...it still feels a bit deceptive haha.

expression is not supported in FF, so it is best to use JS to control dynamic assignment.

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