css布局

布局

弹性布局:

  1. 关键字:display:flex
  2. justify-content:space-between 两端对齐,中间自适应
  3. justify-content:space-around 均匀分布,两边距离等于中间间距
  4. justify-content:space-evenly 平等均匀分布,两边距离是一样的
  5. justify-content:flex-start 默认分布,从弹性开始的地方
  6. justify-content:flex-end 从弹性结束的地方分布
  7. flex-direction:row 行排列 把row换成row-reverse会实现反转
  8. flex-direction:column 竖排列 把column换成column-reverse同样会实现反转
  9. flex-items-wrap:nowrap 控制当前不换行 把nowrap换成wrap就是换行
  10. align-items:center 竖向排列方式 注意!当前父盒子必须有一定的高度
  11. align-items:flex-start 竖向排列默认从弹性开始
  12. align-items:flex-end 默认弹性结束分布
  13. align-content:center 竖向紧密排列 必须要搭配上面的换行使用
  14. align-items 垂直方向排列居中 这个是垂直方向松散排列 两边空出来的距离等于中间的距离

多列布局:

  1. column-count 定义分几列
  2. column-rule 定义用什么线
  3. column-rule-width 设置线的粗细

css的代码

复制代码
.box2{
    height: 800px;
    margin: 0px auto;
    /* 弹性布局 */
    display: flex;
    /* 1. 向两端对齐,中间自适应 */
    justify-content: space-between;
    /* 2. 均匀分布,两边空出来的距离等于中间距离 */
    justify-content: space-around;
    /* 3. 平等均匀分布,距离完全一样 */
    justify-content: space-evenly;
    /* 4. 默认从弹性开始的地方分布 */
    justify-content: flex-start;
    /* 5. 从弹性结束的地方分布 */
    justify-content: flex-end;
    /* 排列方式是按照行还是按照列,默认是正序行(row),reverse:反转布局 */
    /* 6. 行的倒序 */
    flex-direction: row-reverse;
    /* 7. 列的倒序 */
    flex-direction: column-reverse;
    /* 8. 换行,默认不换行(nowrap),只要看到wrap就是换行 */
    flex-wrap: wrap;
    /* 竖向排列方式 */
    /* 当前父盒子必须有一定高度 */
    /* 9. 竖向中间分布,垂直方向松散排列,两边空出来的距离等于中间距离 */
    align-items: center;
    /* 10. 默认弹性开始分布 */
    align-items: flex-start;
    /* 11. 默认弹性结束分布 */
    align-items: flex-end;
    /* 12. 必须搭配换行使用(flex-wrap: wrap;)垂直方向紧密排列 */
    align-content: center;
}
复制代码

html的代码

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css01.css">
</head>
<body>
    <div class="box1">
        <div class="box2">
            <div class="box3">1</div>
            <div class="box3">2</div>
            <div class="box3">3</div>
            <div class="box3">4</div>
            <div class="box3">5</div>
            <div class="box3">6</div>
            <div class="box3">7</div>
            <div class="box3">8</div>
            <div class="box3">9</div>
        </div>
    </div>
</body>
</html>
复制代码

 

posted @   Lib_zyz  阅读(17)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示