当前位置:网站首页>对于flex:1的详细解释,flex:1
对于flex:1的详细解释,flex:1
2022-06-24 06:55:00 【imkaifan】
flex:1 是三个属性的连写:flex-grow、flex-shrink、flex-basis
flex-grow:属性定义的是项目的方法比例,默认为 0,即如果存在剩余空间,也不会去放大
如果所有的项目的flex-grow都为1,则他们将等分剩余空间。
如果一个项目的flex-grow属性为2,其他的都为1,那么前者占据的剩余空间会比其他项多一倍。
flex-shrink:属性定义了项目的缩小比例,默认为1,即:如果空间不足,就将改项目缩小。
如果所有项目的flex-shrink属性为1,当空间不足时,就都等比例缩小。
如果一个项目的flex-shrink属性为0,其他的项目都为1,当空间不足的时候,为0的不缩小。
flex-basis:属性定义了在分配多余空间之前,项目占据的主轴空间。
浏览器根据这个属性,计算主轴是否有多余空间,它的默认值为auto,也就是项目本来的大小
它可以设为跟width或height属性一样的值(比如350px),则项目将占据固定空间。
并且basis和width同时存在basis会把width干掉
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 500px;
height: 100px;
background-color: hotpink;
display: flex;
}
.box div {
width: 100px;
}
.box div:nth-child(1) {
flex-basis: 50px;
}
.box div:nth-child(2) {
flex-basis: 100px;
}
.box div:nth-child(3) {
flex-basis: 50px;
}
</style>
</head>
<body>
<div class="box">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
</body>
</html>

flex:flex属性是flex-grow, flex-shrink 和 flex-basis的简写,默认值为0 1 auto
该属性有两个快捷值:auto (1 1 auto) 和 none (0 0 auto)。
边栏推荐
- 一文理解同步FIFO
- Jenkins 太老了 试试它?云原生 CI/CD Tekton
- 模型效果优化,试一下多种交叉验证的方法(系统实操)
- SCM stm32f103rb, BLDC DC motor controller design, schematic diagram, source code and circuit scheme
- Oracle advanced SQL qualified query
- [nilm] non intrusive load decomposition module nilmtk installation tutorial
- Moonwell Artemis现已上线Moonbeam Network
- Standing at the center of the storm: how to change the engine of Tencent
- Synchronous FIFO
- Chapter 1 overview of canvas
猜你喜欢

单片机STM32F103RB,BLDC直流电机控制器设计,原理图、源码和电路方案
![[008] filter the table data row by row, jump out of the for cycle and skip this cycle VBA](/img/a0/f03b8d9c8f5e53078c38cce11f8ad3.png)
[008] filter the table data row by row, jump out of the for cycle and skip this cycle VBA

Practice of opengauss database on CentOS, configuration

Chapter 3: drawing triangles

Introduction of model compression tool based on distiller

Leetcode 207: course schedule (topological sorting determines whether the loop is formed)

Keep one decimal place and two decimal places

uniapp uni-app H5 端如何取消 返回按钮的显示 autoBackButton不生效

SVN实测常用操作-记录操作大全

语料库数据处理个案实例(句子检索相关个案)
随机推荐
Common array encapsulation
Moonwell Artemis现已上线Moonbeam Network
单片机STM32F103RB,BLDC直流电机控制器设计,原理图、源码和电路方案
Exness: Powell insisted on his anti inflation commitment and pointed out that recession is possible
[data update] Xunwei comprehensively upgraded NPU development data based on 3568 development board
力扣(LeetCode)174. 地下城游戏(2022.06.23)
First acquaintance with JUC - day01
Duilib display memory picture
Echart's experience (I): about y axis yaxis attribute
Standing at the center of the storm: how to change the engine of Tencent
Any remarks
Basics of reptile B1 - scrapy (learning notes of station B)
In the post epidemic era, the home service robot industry has just set sail
Practice of opengauss database on CentOS, configuration
JDBC 在性能测试中的应用
站在风暴中心:如何给飞奔中的腾讯更换引擎
Chapter 3: drawing triangles
Jenkins is too old try it? Cloud native ci/cd Tekton
基于Distiller的模型压缩工具简介
Synchronous FIFO