Home  >  Article  >  php教程  >  Comprehensive understanding of the uses of flex

Comprehensive understanding of the uses of flex

高洛峰
高洛峰Original
2016-12-27 16:27:101108browse

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

For example: html code:

<div class="container">
    <div class="box">
 
    </div>
    </div>

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;

ps: This way you can center it horizontally and vertically

2. Flex properties

<div class="items">
    <div class="item">1</div>
    <div class="item">23</div>
    <div class="item">4</div>
    </div>

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 the item:

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

The above is all the content that the editor has brought to you to fully understand the use of flex. I hope you will support the PHP Chinese website~

For more articles related to a comprehensive understanding of the use of flex, please pay attention to the PHP Chinese website!


Statement:
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