1. Flex layout .father { display: flex; justify-content: center; align-items: center; } This method is not compatible 2. Position + transform .son { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } IE9 and below do not support the transform attribute 3. table + table-cell .father { display: table; } .son { display: table-cell; vertical-align: middle; text-align: center; } 4. :before + display:inline-block .father { text-align: center; } .father::before { content: ''; display: inline-block; height: 100%; vertical-align: middle; } .son { display: inline-block; } This concludes this article about several ways to use CSS3 variable height and width vertical and horizontal centering. For more information about CSS3 variable height and width vertical and horizontal centering, please search 123WORDPRESS.COM’s previous articles or continue browsing the following related articles. I hope you will support 123WORDPRESS.COM in the future! |
<<: Solutions to browser interpretation differences in size and width and height in CSS
>>: Complete guide to using iframe without borders or borders (practical experience summary)
Table of contents map filter some every findIndex...
Table of contents Listener watch Format Set up th...
What is the purpose of creating your own website u...
<br />The solution steps are as follows: Sta...
glibc is the libc library released by gnu, that i...
Since its release in 2013, Docker has been widely...
If you want to display extra text as ellipsis in ...
0. System requirements CPU I5-10400F or above Mem...
A major feature of the WeChat 8.0 update is the s...
This article shares the specific code of Bootstra...
Demand scenario: The boss asked me to use the cra...
If a website is widescreen, you drag the browser ...
Understanding of polling In fact, the focus of po...
Today, when verifying the concurrency problem of ...
1. Enter the directory where your project war is ...