How to vertically align elements in a container with css

王林
Release: 2020-07-02 17:13:32
forward
2637 people have browsed it

How to vertically align elements in a container with css

You can use CSS3 Transform to achieve vertical alignment of elements in the container.

(Recommended learning:css quick start)

Specific code implementation:

.verticalcenter{ position: relative; top: 50%; -webkit-transform: translateY(-50%); -o-transform: translateY(-50%); transform: translateY(-50%); }
Copy after login

Use this technique to go from single line text to paragraph to boxes will be aligned vertically.

At present, browser support for Transform requires attention. Chrome 4, Opera 10, Safari 3, Firefox 3, and Internet Explorer 9 all support this attribute.

The above is the detailed content of How to vertically align elements in a container with css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:juejin.im
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!