css弹性盒模型详解----flex-direction

本篇文章详细介绍flex-direction

	flex-direction 是控制盒模型容器下一级子元素的排列方式的属性 一共有四种
		row(默认值):主轴为水平方向,起点在左端。
		row-reverse:主轴为水平方向,起点在右端。
		column:主轴为垂直方向,起点在上沿。
		column-reverse:主轴为垂直方向,起点在下沿。
//第一种属性  flex-direction:row  该属性默认存在即创建了盒模型就会是默认这一条  行排列 靠左
<style>
    .flex-box{
         display: flex;
     }
    
     .box1{
         width: 100px;
         height: 100px;
         background-color: red;
     }.box2{
         width: 100px;
         height: 100px;
         background-color: purple;
     }
 </style>
<div class="flex-box">
    <div class="box1"></div>
    <div class="box2"></div>
</div>
效果演示如下: //在演示中可以看出来两个盒子box1和box2 没有浮动 没有定位也没有改变作用域 就在一行显示

flex-direction:row

//第二种属性 flex-direction: row-reverse;:主轴为水平方向,起点在右端。  该 行排列 靠右
<!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>Document</title>
    <style>
        .flex-box{
            display: flex;
            flex-direction: row-reverse;
        }
       
        .box1{
            width: 100px;
            height: 100px;
            background-color: red;
        }.box2{
            width: 100px;
            height: 100px;
            background-color: purple;
        }
    </style>
</head>
<body>
    <div class="flex-box">
        <div class="box1"></div>
        <div class="box2"></div>
    </div>
</body>
</html>

效果演示如下:

flex-direction: row-reverse;

//第三种属性 flex-direction: column:主轴为垂直方向,起点在左端。   列排序 由上向下正常排列

<!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>Document</title>
    <style>
        .flex-box{
            display: flex;
            flex-direction: column;
        }
       
        .box{
            width: 100px;
            height: 100px;
            background-color: red;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
    <div class="flex-box">
        <div class="box">1111111</div>
        <div class="box">222222</div>
    </div>
</body>
</html>
效果演示如下:

在这里插入图片描述

//第四种属性 flex-direction: column-reverse:主轴为垂直方向,起点在左端。    列排序 由下向上

<!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>Document</title>
    <style>
        .flex-box{
            display: flex;
            flex-direction:column-reverse;
        }
       
        .box{
            width: 100px;
            height: 100px;
            background-color: red;
            margin-bottom: 10px;
            color: blue;
        }
    </style>
</head>
<body>
    <div class="flex-box">
        <div class="box">1111111</div>
        <div class="box">222222</div>
    </div>
</body>
</html>
效果演示如下:

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值