自己测试编辑器中的代码感受一下flex属性。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>flex占比</title> <style type="text/css"> .box { height: 300px; background: blue; display: flex; } .box div { width: 200px; height: 200px; } .box1 { flex: 1; background: red; } .box2 { flex: 3; background: orange; } .box3 { flex: 2; background: green; } </style> </head> <body> <div class="box"> <div class="box1">flex:1</div> <div class="box2">flex:3</div> <div class="box3">flex:2</div> </div> </body> </html>