Home  >  Article  >  Web Front-end  >  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?

王林
王林forward
2020-05-13 09:12:113588browse

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: 单前元素高度;

(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!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete