青草久久影院-青草久久伊人-青草久久久-青草久久精品亚洲综合专区-SM双性精跪趴灌憋尿调教H-SM脚奴调教丨踩踏贱奴

17站長網

17站長網 首頁 編程教程 CSS3教程 查看內容

flex-direction 排列方向

flex-direction 排列方向

彈性和模型中內部的子元素的排列方向可以通過這個屬性修改,那么我們就一起看下它的使用吧。

1. 官方定義

flex-direction 屬性規定項目的排列方向。

2. 解釋

flex-direction 用來調整主軸的方向,我們知道主軸默認是水平方向且從左到右,而我們可以通過這個屬性設置主軸的方向,即項目是水平方向從左到右還是垂直方向從上到下或者從下到上排列。

3. 語法

div{
    flex-direction: row|row-reverse|column|column-reverse|initial|inherit;
}
<div class="demo">
    <div class="item">1</div>
    <div class="item">2</div>
    <div class="item">3</div>
</div>
.demo{
    display:flex; // 讓容器變成彈性盒
    flex-direction:row-reverse; 改變項目的排列方向
}

4. 兼容性

IEEdgeFirefoxChromeSafariOperaiosandroid
10+12+28+4+6.1+12.1+7+4.4

5. 實例

  1. 讓子元素從上到下垂直方向排列

.demo{
    display:flex; 
    flex-direction:column; 
    text-align: center;
    line-height: px;
}
.item{
    background:#ccc;
    height:px;
    border-bottom:px solid #fff;           
}

效果圖

編程之家

從上到下排列效果圖
<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <Meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .demo{
            display:flex; 
            flex-direction:column; 
            text-align: center;
            line-height: px;
        }
        .item{
            background:#ccc;
            height:px;
            border-bottom:px solid #fff;           
        }
    </style>
</head>
<body>
    <div class="demo">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
    </div>
</body>
</html>
  1. 讓子元素從下到上反向排列

.demo{
    display:flex; 
    flex-direction:column-reverse; 
    text-align: center;
    line-height: px;
}
.item{
    background:#ccc;
    height:px;
    border-bottom:px solid #fff;
}

效果圖

編程之家

從上到下反向排列效果圖
<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <Meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .demo{
            display:flex; 
            flex-direction:column-reverse; 
            text-align: center;
            line-height: px;
        }
        .item{
            background:#ccc;
            height:px;
            border-bottom:px solid #fff;           
        }
    </style>
</head>
<body>
    <div class="demo">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
    </div>
</body>
</html>
  1. 讓子元素從左到右排列

.demo{
    display:flex; 
    flex-direction:row; 
}
.item{
    background:#ccc;
    height:px;
    width: px;
    border-right:px solid #fff;           
}

效果圖

編程之家

從左到右排列效果圖
<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <Meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .demo{
            display:flex; 
            flex-direction:row; 
            text-align: center;
            line-height: px;
        }
        .item{
            background:#ccc;
            height:px;
            width: px;
            border-right:px solid #fff;           
        }
    </style>
</head>
<body>
    <div class="demo">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
    </div>
</body>
</html>
  1. 讓子元素從左到右反向排列

.demo{
    display:flex; 
    flex-direction:row-reverse; 
}
.item{
    background:#ccc;
    height:px;
    width: px;
    border-right:px solid #fff;           
}

效果圖

編程之家

從左到右反向排列效果圖
<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <Meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .demo{
            display:flex; 
            flex-direction:row-reverse; 
            text-align: center;
            line-height: px;
        }
        .item{
            background:#ccc;
            height:px;
            width: px;
            border-right:px solid #fff;           
        }
    </style>
</head>
<body>
    <div class="demo">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
    </div>
</body>
</html>

6. 經驗分享

通過 flex 可以做一個上下固定,中間自適應的布局,它常常用于登錄頁那類的布局設置。

<div class="demo">
    <div class="head">頭部</div>
    <div class="content">內容</div>
    <div class="foot">尾部</div>
</div>
html,body{
    padding:;
    margin:;
    height: ;
    color:#fff;
}
.demo{
    height: ;
    display: flex;
    flex-direction: column;
}
.head,.foot{
    
    flex:  px;
    background: #000;
}
.content{
    flex: ;
    background: red;
}

案例:

<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <Meta name="viewport" content="width=device-width, initial-scale=1.0">
    <Meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>demo</title>
    <style>
    html,body{
        padding:;
        margin:;
        height: ;
        color:#fff;
    }
    .demo{
        height: ;
        display: flex;
        flex-direction: column;
    }
    .head,.foot{
        
        flex:  px;
        background: #000;
    }
    .content{
        flex: ;
        background: red;
    } 
    </style>
</head>
<body>
<div class="demo">
    <div class="head">頭部</div>
    <div class="content">內容</div>
    <div class="foot">尾部</div>
</div>
</body>
</html>

說明:這個布局就是兩端固定,中間自適應的典型寫法,而如果設置 flex-direction:row就變成了左右固定,中間自適應的橫向布局。而他們正是組成頁面的基礎。

7. 小結

  1. 一定要在彈性盒模型下使用。

  2. 可以通過樣式直接設置排列順序,節省瀏覽器性能。

返回頂部
主站蜘蛛池模板: 人妻免费久久久久久久了 | 欧美末成年videos丨 | 日本黄 色大片全 | 富婆找黑人老外泻火在线播放 | 80岁色老头69av | 啦啦啦WWW在线观看免费高清版 | 青春草久久 | 亚洲精品成人a | 国语自产拍在线视频普通话 | 午夜看片网| 中文字幕在线视频观看 | 亚洲精品国产熟女久久久 | 叔叔 电影完整版免费观看韩国 | 欧美成人猛片aaaaaaa | 99久久国产露脸精品麻豆 | 99久久精品国产自免费 | 沈阳熟女露脸对白视频 | 毛篇片在线观看 | 国产成人精品免费视频软件 | 秋霞伦理电影在2017韩国在线伦 | 国产精品俺来也在线观看 | 99热在线视频这里只精品 | 亚洲幼女网 | 2022国产麻豆剧传媒剧情 | 九九热在线观看 | 精品丰满人妻无套内射 | 啪啪激情婷婷久久婷婷色五月 | 国产AV亚洲精品久久久久软件 | 国产色综合久久无码有码 | 国产毛片女人18水多 | 亚洲国产日韩a精品乱码 | 久久国产影院 | 胸大美女又黄的网站 | 插我一区二区在线观看 | 国产精品97久久久久久AV色戒 | 免费成人小视频 | 九九热在线观看视频 | 国产精品高清在线观看地址 | 丝瓜涩涩屋黄瓜香蕉丝瓜 | 琪琪伦伦影院理论片 | 午夜向日葵高清在线观看 |