当前位置:网站首页>对于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)。
边栏推荐
- 软件工程导论——第三章——需求分析
- Chapter 3: drawing triangles
- 4-操作列表(循环结构)
- 闲谈:3AC到底发生了什么?
- Inline element, block element, inline block element
- Do you still have the opportunity to become a machine learning engineer without professional background?
- Echart's experience (I): about y axis yaxis attribute
- 一文理解同步FIFO
- Jenkins is too old try it? Cloud native ci/cd Tekton
- Hongmeng OS development III
猜你喜欢

解决笔记本键盘禁用失败问题

First acquaintance with JUC - day01

开放合作,共赢未来 | 福昕鲲鹏加入金兰组织

从 jsonpath 和 xpath 到 SPL

Oracle-高级SQL限定查询

Echart's experience (I): about y axis yaxis attribute

单片机STM32F103RB,BLDC直流电机控制器设计,原理图、源码和电路方案

闲谈:3AC到底发生了什么?

Basics of reptile B1 - scrapy (learning notes of station B)

On the H5 page, the Apple phone blocks the content when using fixed to locate the bottom of the tabbar
随机推荐
3-列表简介
免费ICP域名备案查接口
保留一位小数和保留两位小数
用Ngrok 配置属于自己的免费外网域名
火线,零线,地线,你知道这三根线的作用是什么吗?
. No main manifest attribute in jar
Oracle advanced SQL qualified query
Chapter 4 line operation of canvas
What is the lifecycle of automated testing?
热赛道上的冷思考:乘数效应才是东数西算的根本要求
Review of postgraduate English final exam
Common array encapsulation
OC Extension 检测手机是否安装某个App(源码)
解决 These dependencies were not found: * core-js/modules/es6.array.fill in xxx 之类的问题
开放合作,共赢未来 | 福昕鲲鹏加入金兰组织
UTC、GMT、CST
[测试开发]初识软件测试
单片机STM32F103RB,BLDC直流电机控制器设计,原理图、源码和电路方案
Duilib display memory picture
BOM notes