Home >Web Front-end >HTML Tutorial >How to set a div to be centered horizontally and vertically? _html/css_WEB-ITnose

How to set a div to be centered horizontally and vertically? _html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-24 12:18:561400browse

How to set a div to be centered horizontally and vertically?
Note that it is not the content of the div that is centered horizontally and vertically, but the div itself.
What I found online is that the content of the div is centered horizontally and vertically.
If you want to center it horizontally, margin:0 auto; will work.
I tried many things vertically but nothing worked.


Reply to discussion (solution)

http://www.cnblogs.com/yjzhu/archive/2012/11/19/2773209.html
http:/ /www.w3cplus.com/css/vertically-center-content-with-css
I have written two articles, I hope it will be helpful to LZ.

http://www.cnblogs.com/yjzhu/archive/2012/11/19/2773209.html
http://www.w3cplus.com/css/vertically-center-content- with-css
I have posted two articles, I hope it will be helpful to LZ.
Thanks, done

Statement:
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