当前位置: 首页 > news >正文

flex弹性盒子常用的布局属性详解

想必大家在开发中经常会用到flex布局。而且还会经常用到   justify-content  属性实现分栏等等

接下来给大家分别讲一下  justify-content 的属性值。

以下是我敲的效果图大家可以清晰看出区别

space-between 属性值可以就是说两端对齐

space-evenly 属性值是每个盒子之间的间距相同

space-around 属性值是第一个盒子和最后一个盒子他们是相邻元素之间距离的一半。

如果大家还是不清楚可以建个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>

</head>

<style>

    .boxs1 {

        display: flex;

        justify-content: space-between;

        margin-top: 20px;

    }

    .boxs2 {

        display: flex;

        justify-content: space-evenly;

        margin-top: 20px;

    }

    .boxs3 {

        display: flex;

        justify-content: space-around;

        margin-top: 20px;

    }

    .box {

        width: 200px;

        height: 200px;

        background-color: pink;

        margin-left: 20px;

    }

    .box1 {

        width: 200px;

        height: 200px;

        background-color: royalblue;

        margin-left: 20px;

    }

    .box2 {

        width: 200px;

        height: 200px;

        background-color: red;

        margin-left: 20px;

    }

    .box3 {

        width: 200px;

        height: 200px;

        background-color: blanchedalmond;

        margin-left: 20px;

    }

    .box4 {

        width: 200px;

        height: 200px;

        background-color: blue;

        margin-left: 20px;

    }

</style>

<body>

    <div class="boxs1">

        <div class="box"></div>

        <div class="box1"></div>

        <div class="box2"></div>

        <div class="box3"></div>

        <div class="box4"></div>

    </div>

    <div class="boxs2">

        <div class="box"></div>

        <div class="box1"></div>

        <div class="box2"></div>

        <div class="box3"></div>

        <div class="box4"></div>

    </div>

    <div class="boxs3">

        <div class="box"></div>

        <div class="box1"></div>

        <div class="box2"></div>

        <div class="box3"></div>

        <div class="box4"></div>

    </div>

</body>

</html>

http://www.lryc.cn/news/278808.html

相关文章:

  • 2023年Gartner® DevOps平台魔力象限发布,Atlassian被评为“领导者”
  • kylin集群使用nginx反向代理
  • 小红书搜索团队提出全新框架:验证负样本对大模型蒸馏的价值
  • 汽车销售领域相关专业术语
  • 代币合约 ERC20 Token接口
  • 判断回文字符串—C语言
  • 如何在Docker本地搭建流程图绘制神器draw.io并实现公网远程访问
  • Web前端篇——el-timeline+el-scrollbar时间轴数据刷新后自动显示滚动条
  • Flutter 监听前台和后台切换的状态
  • 图解Kubernetes的服务(Service)
  • facebook广告素材制作要注意哪些
  • Android 应用流量监控实践
  • 并发前置知识一:线程基础
  • 计算机网络 物理层
  • 浅谈轻量级Kubernetes—K3s
  • Web APIs知识点讲解
  • Python商业数据挖掘实战——爬取网页并将其转为Markdown
  • 初识 Elasticsearch 应用知识,一文读懂 Elasticsearch 知识文集(1)
  • StampedLock详解
  • Linux中DCHP与时间同步
  • 国产系统-银河麒麟桌面版V10安装字体-wps安装字体
  • python 10常用自动化脚本收藏好
  • java物品检验管理系统Myeclipse开发mysql数据库web结构java编程计算机网页项目
  • Pandas实战100例 | 案例 2: 数据探索 - 查看和理解数据
  • c++qt-基本组件
  • SpringBoot多环境配置Maven Profile组
  • 服务器配置 ssh 密钥登录
  • 使用递归将list转换成tree
  • untiy使用http下载资源
  • 03-编码篇-x264编译与介绍