Code for display: flex attribute in css to implement vertical centering of elements

不言
Release: 2018-08-06 17:00:56
Original
2901 people have browsed it

This article introduces to you the display: flex attribute in CSS to implement the code for vertical centering of elements. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Before this, I used absolute positioning absolute or fixed positioning fixed

How to use flex to vertically center elements, the parent includes the child

boxboxboxboxboxboxboxboxboxboxbox
.itemBox{ display: flex; justify-content: center; align-items: center; background: #588cfe; width: 100%; height: 100vh; } .itemBox p{ background: #ffffff; width: 200px; height: 200px; word-break: break-all;//英文超出盒子不换行问题 }
Copy after login

Recommended related articles:

Code for text-transform attribute in CSS to implement string conversion

Two ways to use tables in CSS (examples)

The above is the detailed content of Code for display: flex attribute in css to implement vertical centering of elements. 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
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!