Home > Web Front-end > CSS Tutorial > What are the commonly used horizontal and vertical center alignment methods in CSS?

What are the commonly used horizontal and vertical center alignment methods in CSS?

王林
Release: 2020-05-13 09:12:11
forward
3686 people have browsed it

What are the commonly used horizontal and vertical center alignment methods in CSS?

1. Horizontal and vertical centering of text

text-align: center;    
line-height: 单前元素高度;
Copy after login

(Video tutorial recommendation: css video tutorial)

2. Horizontal and vertical centering of elements

1. Use absolute positioning

What are the commonly used horizontal and vertical center alignment methods in CSS?

2. Use absolute positioning calc()

What are the commonly used horizontal and vertical center alignment methods in CSS?

3. Use absolute positioning transform

What are the commonly used horizontal and vertical center alignment methods in CSS?

4. Use display:flex;

What are the commonly used horizontal and vertical center alignment methods in CSS?

Recommended tutorial: css quick start

The above is the detailed content of What are the commonly used horizontal and vertical center alignment methods in CSS?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:cnblogs.com
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