1. Flex is the abbreviation of Flexible Box, which means "flexible layout" and is used to provide maximum flexibility for the box model. Any container can be specified as a Flex layout. Note that after setting the Flex layout, the float, clear and vertical-align properties of the child elements will become invalid. Elements that use Flex layout are called Flex containers, or "containers" for short. All its child elements automatically become container members, called Flex items, or "items" for short. By default, a container has two axes: the horizontal main axis and the vertical cross axis. The starting position of the main axis (the intersection with the border) is called the main start, and the ending position is called the main end; the starting position of the cross axis is called the cross start, and the ending position is called the cross end. Items are arranged along the main axis by default. The main axis space occupied by a single item is called the main size, and the cross axis space occupied is called the cross size. flex-direction flex-wrap flex-flo justify-content align-items align-content 2. Vertical centering of elements within a block <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>About vertical centering of elements</title> <style> html, body { border: 0; margin: 0; padding: 0; height: 100%; width: 100%; } .div-main { display: flex; align-items: center; justify-content: center; height: 30%; width: 50%; background: #00a2d4; } .sub-span { margin: auto; font-size: xx-large; } </style> </head> <body> <div class="div-main"> <span class="sub-span"> The Goddess of Luo River </div> </body> </html> This is the end of this article about examples of vertically centering sub-elements inside a div using Flex layout. For more information about vertically centering sub-elements inside a div using Flex, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope that everyone will support 123WORDPRESS.COM in the future! |
<<: Various methods to implement the prompt function of text box in html
>>: Analysis of the reasons why MySQL's index system uses B+ tree
1. Single row overflow 1. If a single line overfl...
We better start paying attention, because HTML Po...
This article records the installation of MySQL 8....
1. Introduction to mysqlbackup mysqlbackup is the...
Whether MySQL needs to commit when performing ope...
1. Problem reproduction: Count the total number o...
Table of contents Preface Install Introduction Sw...
Now there are many WeChat public account operatio...
Preface In LINUX, periodic tasks are usually hand...
Table of contents App.vue sub1.vue sub2.vue Summa...
Preface In JavaScript, you need to use document.q...
Preface This experiment prepares two virtual mach...
Table of contents Preface 1. Basic usage of liste...
How to define complex components (class component...
After purchasing an Alibaba Cloud server, you nee...