精品免费在线观看-精品欧美-精品欧美成人bd高清在线观看-精品欧美高清不卡在线-精品欧美日韩一区二区

17站長(zhǎng)網(wǎng)

flex-direction 排列方向

flex-direction 排列方向

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

1. 官方定義

flex-direction 屬性規(guī)定項(xiàng)目的排列方向。

2. 解釋

flex-direction 用來(lái)調(diào)整主軸的方向,我們知道主軸默認(rèn)是水平方向且從左到右,而我們可以通過(guò)這個(gè)屬性設(shè)置主軸的方向,即項(xiàng)目是水平方向從左到右還是垂直方向從上到下或者從下到上排列。

3. 語(yǔ)法

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; 改變項(xiàng)目的排列方向
}

4. 兼容性

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

5. 實(shí)例

  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. 經(jīng)驗(yàn)分享

通過(guò) flex 可以做一個(gè)上下固定,中間自適應(yīng)的布局,它常常用于登錄頁(yè)那類的布局設(shè)置。

<div class="demo">
    <div class="head">頭部</div>
    <div class="content">內(nèi)容</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">內(nèi)容</div>
    <div class="foot">尾部</div>
</div>
</body>
</html>

說(shuō)明:這個(gè)布局就是兩端固定,中間自適應(yīng)的典型寫(xiě)法,而如果設(shè)置 flex-direction:row就變成了左右固定,中間自適應(yīng)的橫向布局。而他們正是組成頁(yè)面的基礎(chǔ)。

7. 小結(jié)

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

  2. 可以通過(guò)樣式直接設(shè)置排列順序,節(jié)省瀏覽器性能。

返回頂部
主站蜘蛛池模板: 一级毛片在线播放免费 | 久草在线视频精品 | 在线观看国产情趣免费视频 | 欧美一级性生活视频 | 欧美日韩一区二区三区视视频 | 日韩高清在线免费观看 | 色婷婷丁香六月 | 一级毛片免费不卡 | 欧美成人午夜精品免费福利 | 性欧美高清come | 久久国产成人精品国产成人亚洲 | 久久99精品国产99久久 | 久草视频在线播放 | 精选国产门事件福利在线观看 | 性满足久久久久久久久 | 日本免费观看95视频网站 | 国内视频一区二区 | 国产成人在线观看免费网站 | 亚州中文字幕 | 成人免费视频无遮挡在线看 | 国产亚洲精品久久久久久久网站 | 中文国产成人精品久久无广告 | 在线观看麻豆国产精品 | 黄网站在线播放视频免费观看 | 国产换爱交换乱理伦片 | 黑人操中国美女 | 亚洲福利国产 | xxxxx性视频免费播放 | 国产成人精品在线 | 日日噜噜夜夜狠狠tv视频免费 | 亚洲一区二区三区高清网 | 国产综合色在线视频播放线视 | 国产在线一区精品对白麻豆 | 深夜影院在线视频观看 | 亚洲欧美国产精品第1页 | 97久久久久国产精品嫩草影院 | 久久国产影视免费精品 | 久久在线免费视频 | 国产精品久久久久久影视 | 激情小视频在线播放免费 | 一级女性全黄久久生活片 |