美文网首页
CSS Flex flex-direction

CSS Flex flex-direction

作者: GaoEnron | 来源:发表于2019-12-28 20:50 被阅读0次

Flex属性学习

1.0 flex-direction 属性排列

column-reverse: 列反向排列

实例:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" content="width=device-width, initial-scale=1.0">
        <title></title>
        <style type="text/css">
            * {
                padding: 0px;
                margin: 0px;
            }
            
            body {
                padding-left: 0px;
                padding-top: 100px;
            }
            
            article {
                display: flex;
                border: solid 5px blueviolet;
                width: 300px;
                flex-direction: column-reverse;
            }
            
            
            article * {
                width: 100px;
                height: 100px;
                background: red;
                margin: 10px;
            }
            
            .first {
                background: #87CEEB;
            }
            
            .second {
                background: #FFA07A;
            }
            
            .third {
                background: lightpink;
            }
            .fourth {
                background: lightgreen;
            }
        
        </style>
    </head>
    <body>
        <article>
            <div class="first">第一</div>
            <div class="second">第二</div>
            <div class="third">第三</div>
            <div class="fourth">第四</div>
        </article>
    </body>
</html>

屏幕快照 2019-12-28 下午8.14.10.png

1.0 flex-direction 属性排列

column-reverse: 列反向排列

实例:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" content="width=device-width, initial-scale=1.0">
        <title></title>
        <style type="text/css">
            * {
                padding: 0px;
                margin: 0px;
            }
            
            body {
                padding-left: 0px;
                padding-top: 100px;
            }
            
            article {
                display: flex;
                border: solid 5px blueviolet;
                width: 300px;
                flex-direction: column-reverse;
            }
            
            
            article * {
                width: 100px;
                height: 100px;
                background: red;
                margin: 10px;
            }
            
            .first {
                background: #87CEEB;
            }
            
            .second {
                background: #FFA07A;
            }
            
            .third {
                background: lightpink;
            }
            .fourth {
                background: lightgreen;
            }
        
        </style>
    </head>
    <body>
        <article>
            <div class="first">第一</div>
            <div class="second">第二</div>
            <div class="third">第三</div>
            <div class="fourth">第四</div>
        </article>
    </body>
</html>

屏幕快照 2019-12-28 下午8.14.10.png

1.1 flex-direction: row

元素横向排列

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" content="width=device-width, initial-scale=1.0">
        <title></title>
        <style type="text/css">
            * {
                padding: 0px;
                margin: 0px;
            }
            
            body {
                padding-left: 0px;
                padding-top: 100px;
            }
            
            article {
                display: flex;
                border: solid 5px blueviolet;
                width: 300px;
                flex-direction: row;
            }
            
            
            article * {
                width: 100px;
                height: 100px;
                background: red;
                margin: 10px;
            }
            
            .first {
                background: #87CEEB;
            }
            
            .second {
                background: #FFA07A;
            }
            
            .third {
                background: lightpink;
            }
            .fourth {
                background: lightgreen;
            }
        
        </style>
    </head>
    <body>
        <article>
            <div class="first">第一</div>
            <div class="second">第二</div>
            <div class="third">第三</div>
            <div class="fourth">第四</div>
        </article>
    </body>


</html> 屏幕快照 2019-12-28 下午8.55.55.png

1.0 flex-direction 属性排列

column-reverse: 列反向排列

实例:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" content="width=device-width, initial-scale=1.0">
        <title></title>
        <style type="text/css">
            * {
                padding: 0px;
                margin: 0px;
            }
            
            body {
                padding-left: 0px;
                padding-top: 100px;
            }
            
            article {
                display: flex;
                border: solid 5px blueviolet;
                width: 300px;
                flex-direction: column-reverse;
            }
            
            
            article * {
                width: 100px;
                height: 100px;
                background: red;
                margin: 10px;
            }
            
            .first {
                background: #87CEEB;
            }
            
            .second {
                background: #FFA07A;
            }
            
            .third {
                background: lightpink;
            }
            .fourth {
                background: lightgreen;
            }
        
        </style>
    </head>
    <body>
        <article>
            <div class="first">第一</div>
            <div class="second">第二</div>
            <div class="third">第三</div>
            <div class="fourth">第四</div>
        </article>
    </body>
</html>

屏幕快照 2019-12-28 下午8.14.10.png

1.1 flex-direction: row

元素横向排列

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" content="width=device-width, initial-scale=1.0">
        <title></title>
        <style type="text/css">
            * {
                padding: 0px;
                margin: 0px;
            }
            
            body {
                padding-left: 0px;
                padding-top: 100px;
            }
            
            article {
                display: flex;
                border: solid 5px blueviolet;
                width: 300px;
                flex-direction: row;
            }
            
            
            article * {
                width: 100px;
                height: 100px;
                background: red;
                margin: 10px;
            }
            
            .first {
                background: #87CEEB;
            }
            
            .second {
                background: #FFA07A;
            }
            
            .third {
                background: lightpink;
            }
            .fourth {
                background: lightgreen;
            }
        
        </style>
    </head>
    <body>
        <article>
            <div class="first">第一</div>
            <div class="second">第二</div>
            <div class="third">第三</div>
            <div class="fourth">第四</div>
        </article>
    </body>


屏幕快照 2019-12-28 下午8.55.55.png

行反向排列

      article {
                display: flex;
                border: solid 5px blueviolet;
                width: 300px;
                flex-direction: row-reverse;
                }
屏幕快照 2019-12-28 下午9.47.14.png

相关文章

网友评论

      本文标题:CSS Flex flex-direction

      本文链接:https://www.haomeiwen.com/subject/fvxeoctx.html