zoukankan      html  css  js  c++  java
  • Flex布局05:flex-container& flex-wrap & flex-flow & align-content

    • flex-wrap : 决定了flex container是单行显示还是多行显示

      • nowrap 默认: 单行,flex-items多了之后压缩flex-items然后显示在一行

        image-20210224140100817

      • wrap:多行 不压缩尺寸直接换行显示

        image-20210224140247743

      • flex-flow: flex-direction && flex-wrap缩写

        flex-flow: row-reverse wrap;
        
      • align-content: 决定多行flex-items 在交叉轴 的对齐方式

        image-20210224141042022

    代码

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    
        <style>
            #box{
                /* 开启flex布局:块元素 */
                display: flex;
                /* 开启flex布局;行元素 */
                /* display: inline-flex; */
                background-color: red;
                 600px;
                height: 500px;
                
                /* 水平居中 */
                margin: 0 auto;
    
                /* row: 默认值从main start -> main end
                row-reverse: 反转 从右到左
                column : 从上倒下
                column-reverse: 从下到上
                */
                /* flex-direction: row-reverse; */
    
                /* flex-start: 默认值 main start对齐 
                flex-end: main end 对齐
                center: 主轴中间对齐
                space-between: 左右对齐等分主轴
                space-around: 左右等分间隙然后等分
                space-evenly: 左右窄,中间等分
                */
                /* justify-content: space-around; */
    
                /*
                align-items: 决定flex-items在交叉轴的对齐方式 
                flex-start: 在交叉轴的顶部对齐
                flex-end: 在交叉轴的底部对齐
                center: 在交叉轴的中心点对齐
                baseline: 基线对齐(第一行文本作为基线)
                 */
                align-items: center;
                /* flex-wrap: 决定当flex-items的总宽度/长度 超过flex-contianer 换行显示 */
                flex-wrap: wrap;
    
                /* flex-flow : flex-direction && flex-wrap缩写 */
                /* flex-flow: row-reverse wrap; */
    
                align-content: center;
    
            }
            .item{
                text-align: center;
                height: 300px;
                 300px;
            }
    
            .item1{
                background-color: azure;
            }
            .item2{
                background-color: green;
            }
            .item3{
                background-color: gold;
            }
        </style>
    </head>
    <body>
    
        <div id="box">
            <div class="item item1">item1</div>
            <div class="item item2">item2</div>
            <div class="item item3">item3</div>
            <!-- <div class="item item4">item4</div> -->
        </div>
    
        <strong>行类元素</strong>
    
    
        
    </body>
    </html>
    
    作者:zy7y
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文链接,否则保留追究法律责任的权利。
  • 相关阅读:
    win8下Source Insight has not been installed completely问题的解决
    linux命令学习——ps
    linux命令学习——file
    树莓派进阶之路 (023)
    树莓派进阶之路 (022)
    树莓派进阶之路 (021)
    树莓派进阶之路 (020)
    ubuntu下安装gedit插件
    C语言学习笔记 (004)
    C语言学习笔记 (003)
  • 原文地址:https://www.cnblogs.com/zy7y/p/14441141.html
Copyright © 2011-2022 走看看