Detailed explanation of the use of CSS Flex

Guanhui
Release: 2020-07-18 17:47:51
forward
2692 people have browsed it

Detailed explanation of the use of CSS Flex

1. You can use flex to lay out a p and center it horizontally and vertically inside another p

For example: html code:

<p class="container">
	<p class="box">

	</p>
	</p>
Copy after login

css code:

.container{
	width:600px;
	height:400px;
	border:1px solid blue;
	display: flex;
	justify-content:center;
	align-items:center;
	}
	.box{
	width:200px;
	height:100px;
	border:1px red solid;
Copy after login

ps: This way you can center it horizontally and vertically

2. Attributes of flex

<p class="items">
	<p class="item">1</p>
	<p class="item">23</p>
	<p class="item">4</p>
	</p>
Copy after login

There are six attributes that can be written on items:

•flex-direction
•flex-wrap
•flex-flow
•justify-content
•align-items
•align-content

There are 6 items that can be written on items:

•order//This is the item given separately. If you want to change the order of that item, give this attribute to that item
•flex-grow
•flex-shrink
•flex-basis
•flex
•align-self

The above is the detailed content of Detailed explanation of the use of CSS Flex. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template