青草久久影院-青草久久伊人-青草久久久-青草久久精品亚洲综合专区-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. 可以通過樣式直接設置排列順序,節省瀏覽器性能。

返回頂部
主站蜘蛛池模板: 在线广播收听 | 女教师跟黑人男朋友激情过后 | 亚在线观看免费视频入口 | 国产乱子影视频上线免费观看 | 99视频久久精品久久 | 九九免费的视频 | 亚洲一区精品伊人久久伊人 | 亚洲精品m在线观看 | 甜性涩爱全集在线观看 | 日本欧美久久久久免费播放网 | 欧美怡红院视频一区二区三区 | 欧美香蕉大胸在线视频观看 | 男同志在线观看 | 欧美精品乱码99久久蜜桃 | 国际老妇高清在线观看 | xxnxx动漫| 亚洲免费人成在线视频观看 | 亚洲AV永久无码精品澳门 | 成人天堂婷婷青青视频在线观看 | 熟妇无码乱子成人精品 | 双腿被绑成M型调教PLAY照片 | 爱啪国产精品视频在线 | 在线观看国产视频 | 亚洲视频成人 | 暖暖视频大全免费观看 | 思思re热免费精品视频66 | 欧美xxxx83d| 国产自产第一区c国产 | 嫩草影院成人 | 三级黄色小视频 | 18岁男人女人插孔 | 天美传媒色情原创精品 | 美女内射少妇三区五区 | 亚洲 日韩 在线 国产 精品 | 无遮18禁在线永久免费观看挡 | 香蕉99久久久久成人麻豆 | a在线免费观看视频 | 国产美女又黄又爽又色视频网站 | 调教日本美女 | 欧美性xxx免费看片 欧美性xxx极品 | 国产成人高清亚洲一区app |