flex-grow
来源:互联网 发布:网络侦探进化图鉴 编辑:程序博客网 时间:2024/06/07 13:30
1、The sum of the length of the whole inner div < the outer div
<!doctype html><html><head> <style type="text/css"> #main{ border: 1px solid black; width: 150px; height: 300px; display: flex; } #div1{ width: 50px; height: 70px; background-color: pink; flex-grow:2; } #div2{ flex-grow:1; width: 50px; height: 70px; background-color: orange; } #div3{ flex-grow:1; width: 50px; height: 70px; background-color: green; } #div4{ flex-grow:1; width: 50px; height: 70px; background-color: yellow; } </style></head><body> <div id="main"> <div id="div1"></div> <div id="div2"></div> <div id="div3"></div> <div id="div4"></div> </div></body></html>
As you can see in the picture,sum of the length of the four div should be 50*4=200px,but the outer div is 150px,so each div will be reduced to 150/4=37.5px equally.The flex-grow does not work.
2、The sum of the length of the whole inner div > the outer div
<!doctype html><html><head> <style type="text/css"> #main{ border: 1px solid black; width: 400px; height: 300px; display: flex; } #div1{ width: 50px; height: 70px; background-color: pink; flex-grow:2; } #div2{ flex-grow:1; width: 50px; height: 70px; background-color: orange; } #div3{ flex-grow:1; width: 50px; height: 70px; background-color: green; } #div4{ flex-grow:1; width: 50px; height: 70px; background-color: yellow; } </style></head><body> <div id="main"> <div id="div1"></div> <div id="div2"></div> <div id="div3"></div> <div id="div4"></div> </div></body></html>
The flex-grow of div1 is 2,and others is 1,so the width of div1 is 50+2/(2+1+1+1)*(400-50*4)=130px.It just add the proportion of spare space.
0 0
- flex-grow
- flex-grow、flex-shrink、flex-basis详解
- 戏说flex-grow、flex-shrink、flex-basis
- flex-grow、flex-shrink、flex-basis详解
- Flex布局中的Flex-Grow无效问题
- flex-grow、flex-shrink、flex-basis详解、flex:1;详解
- 弹性盒子模型属性之flex-grow
- 深入理解 flex-grow & flex-shrink & flex-basis
- css3 flex属性flex-grow、flex-shrink、flex-basis学习笔记
- css3 flex属性flex-grow、flex-shrink、flex-basis学习笔记
- Flex弹性布局之flex-basis、flex-grow、flex-shrink分析
- Flex入门基础——项目item的属性(order、flex-grow、flex-shrink、flex-basis、flex、align-self)
- HTML5基础加强css样式篇(伸缩容器子元素属性:order,flex-grow,flex-shrink,flex-basis,flex,align-self)(五十四)
- grow up
- GROW THAT DBA CAREER
- Grow That DBA Career
- GROW THAT DBA CAREER
- grow grass on keyboard
- NOI 2014 魔法森林 LCT
- PHP强制转换整形的一点小问题
- mave项目报错:web.xml is missing and <failOnMissingWebXml> is set to true
- ThinkPad T460p 黑苹果安装 - 前篇:在虚拟机上安装MacOS 10.12 Sierra
- Test,数据库
- flex-grow
- 【PAT】1031. Hello World for U
- 数据库
- 踩坑集
- ubuntu 16.04安装mysql-server_5.7.17
- 因为服务器异常关闭导致oracle无法连接
- 数据库
- 链式队列
- 我是如何将投资账本的用户数从0做到50万的