flex properties

A, flex-direction (arrangement direction element)

1, flex-direction: row; // left to right

2, flex-direction: column; // order from the top down

Two, flex-wrap (not tolerate the contents of a row when it is active)

1, flex-wrap: nowrap // beyond does not wrap, strange inside width becomes 100%

2, flex-wrap: wrap // exceed the height divided equally by the parent)

Three, justify-content // horizontal alignment

. 1, justify- Content: Start-Flex ; (left horizontal alignment)

2, justify- Content: End-Flex ; (horizontally right aligned)

. 3, justify- Content: Center ; (centered)

. 4, justify- Content: Space-BETWEEN ; (Justify)

. 5, justify- Content: Space-around ; (justification, and ends spaced)

Four, align-items (vertical alignment)

1, align-items: flex-start; (aligned in, and almost by default)

1, align-items: flex-end; (the alignment)

1, align-items: center; (centered)

The above is a brief introduction to the flex. The following is a quick example,

  We often used, inside a div horizontally and vertically centered,

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            #box{
                display: flex;
                display: -webkit-flex;
                border: 1px solid #0000FF;
                height: 200px;
                width: 400px;
                align-items:center;
                justify-content:center;
            }
            .item{
                width: 50px;
                height: 40px;
                border: 1px solid #00C1B3;
            }
        </style>
    </head>
    <body>
        <div id="box">
            <div class="item">1</div>
            <div class="item">2</div>
            <div class="item">3</div>
            <div class="item">4</div>
            <div class="item">5</div>
        </div>
    </body>
</html>

Guess you like

Origin www.cnblogs.com/maizilili/p/12331901.html