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

How to make text appear vertically centered in css3

王林
Release: 2020-11-20 09:12:45
Original
2722 people have browsed it

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;
Copy after login

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!

Related labels:
source:php.cn
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