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)
Usage of time difference functions TIMESTAMPDIFF ...
This article shares the specific code for JavaScr...
Specific method: 1. Press [ win+r ] to open the r...
Test the efficiency of deleting a large number of...
Optimizing large amounts of database data is a hu...
react-native installation process 1.npx react-nat...
Table of contents Preface Dockerfile What is a Do...
This article mainly introduces the detailed proce...
To merge the following two files, merge them toge...
When making forms, we often encounter the situati...
PHP related paths in Ubuntu environment PHP path ...
introduction In recent years, the call for TypeSc...
This article example shares the specific code of ...
Table of contents Understanding Asynchrony fetch(...
Introduction During the work process, slow querie...