来源:https://www.cnblogs.com/beka/p/8574189.html
flex: flex-grow flex-shrink flex-basis;
flex-flow: flex-direction flex-wrap;
flex-wrap: wrap;//让弹性盒元素在必要的时候拆行
flex-basis 属性用于设置或检索弹性盒伸缩基准值。一个长度单位或者一个百分比,规定灵活项目的初始长度。
<!DOCTYPE html> <html lang="en"> <head> <title></title> <style> .test { display: flex; display: -webkit-flex; justify-content: center; align-items: center; border: 1px solid red; box-sizing: border-box; overflow: hidden; width: 100%; height: 400px; } .top { border: 1px solid blue; -webkit-flex: 1 1 300px; -ms-flex: 1 1 300px; flex: 1 1 300px; width: 200px; height: 200px; } .main { border: 1px solid green; flex: 1 1 300px; width: 200px; height: 200px; } .bottom { border: 1px solid black; flex: 1 1 300px; width: 200px; height: 200px; } </style> </head> <body> <div class="test"> <div class="top">头部</div> <div class="main">中间</div> <div class="bottom">底部</div> </div> <div> <p>flex: 1 1 300px;</p> <p>flex: 扩展比例 收缩比例 基准“宽”度;</p> </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <title></title> <style> </style> </head> <body> <div style="width: 50px;border: 1px solid green;height:50px;"> <div style="max-width: 100px;border: 3px solid gray;height:50px"> </div> </div> <br/> <br/> <div style="width: 50px;border: 1px solid green;height:50px;"> <div style="min-width: 100px;border: 3px solid gray;height:50px"> </div> </div> </body> </html>