Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the Vertical centering of text by css

Shulou Source: shulou.com Published: 2022-06-01 04:49:25 10月03日 Update

This article is to share with you about how css achieves the vertical center of text. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Vertical centering of text

The vertical center of a single line of text, as long as the line height is set to equal to the container height.

For example, there is a row of numbers in the container.

Html Code:

1234567890

Then CSS wrote:

Div#container {height: 35px; line-height: 35px;}

If there are n lines of text, set the line height to one nth of the container height.

Thank you for reading! This is the end of the article on "how to achieve the vertical center of text in css". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Text containers content more articles good practical one line code numbers articles look knowledge height reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Docker OPPO Reno Linux vpn