flex 弹性布局 笔记

发布于:2024-12-18 ⋅ 阅读:(98) ⋅ 点赞:(0)


  <style> 
    /* 
flex-direction (即项目的排列方向)
flex-wrap (换行)
flex-flow ( flex-direction属性和flex-wrap属性的简写形式)
justify-content  (项目的对齐方向)主轴
align-items        (项目的对齐方向)测轴
align-content   ( 多根轴线的对齐方式)

flex-direction: row | row-reverse | column | column-reverse;
flex-direction属性决定主轴的方向(即项目的排列方向)。
row(默认值):主轴为水平方向,起点在左端。
row-reverse:主轴为水平方向,起点在右端。
column:主轴为垂直方向,起点在上沿。
column-reverse:主轴为垂直方向,起点在下沿。
  flex-wrap: nowrap | wrap | wrap-reverse;项目都排在一条线(又称"轴线")上。flex-wrap属性定义,如果一条轴线排不下,如何换行
flex-flow属性是flex-direction属性和flex-wrap属性的简写形式
justify-content属性定义了项目在主轴上的对齐方式 (项目的对齐方向)。

 justify-content: flex-start | flex-end | center | space-between | space-around

 align-items属性定义项目在交叉轴上如何对齐 (项目的对齐方向)。

 align-items: flex-start | flex-end | center | baseline | stretch;
align-content属性定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用
align-content: flex-start | flex-end | center | space-between | space-around | stretch;


    */
    
    .container {
         height: 200px;
      background-color: red;
      display:flex;

        flex-direction:row; 
         justify-content:flex-end; 
/*         align-items:stretch ; */
             align-content:center;  
    }

    *{ border:black 1px solid; }
    .item   { background:blue; 
     color:white; 
     width: 50px;
   /*   height: 50px;*/
     }
 

  </style>
</head>
<body>
 
    <div class="container">
        <div class="item">Item 1</div>
        <div class="item">Item 2</div>
        <div class="item">Item 3</div>
    </div>
 
 


网站公告

今日签到

点亮在社区的每一天
去签到