Home>Article>Web Front-end> How to make text appear vertically centered in css3

How to make text appear vertically centered in css3

王林
王林 Original
2020-11-20 09:12:45 2593browse

css3 method to center text vertically: This can be achieved by using absolute positioning and transform attributes, such as [position:relative; transform:translate(50%,-50%);].

How to make text appear vertically centered in css3

Implementation ideas:

Achieved by using absolute positioning and transform attributes.

(Video tutorial recommendation:css video tutorial)

Property introduction:

The Transform property is applied to the 2D or 3D transformation of the element. This property allows you to rotate, scale, move, tilt, etc. the element.

Grammar:

transform: none|transform-functions;

Test code:

How to make text appear vertically centered in css3

Description:

The very obvious advantage of this method is that it does not have to Know the size of the centered element in advance, because the offset percentage in the transform is relative to the size of the element itself.

Related recommendations:CSS tutorial

The above is the detailed content of How to make text appear vertically centered in css3. For more information, please follow other related articles on the PHP Chinese website!

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