实例首页
自学教程
IT工具箱
源代码
下载代码
上下布局
点击运行 >
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>flex flex-grow、flex-shrink、flex-basis - 自学教程(runoops.com)</title> <style> .container { margin: 10px; display: flex; width: 500px; height: 200px; background-color: #eee; color: #666; text-align: center; } .item { height: 100px; } .item p { margin: 0; } .a { width: 300px; flex-grow: 1; flex-shrink: 0.1; background-color: #ff4466; } .b { width: 150px; flex-shrink: 0.2; background-color: #42b983; } .c { width: 200px; flex-shrink: 0.3; background-color: #61dafb; } </style> </head> <body> <div class="container"> <div class="item a"> <p>A</p> <p> width:300</p> <p>flex-shrink: 1</p> </div> <div class="item b"> <p>B</p> <p> width:150</p> <p>flex-shrink: 2</p> </div> <div class="item c"> <p>C</p> <p> width:200</p> <p>flex-shrink: 3</p> </div> </div> </body> </html>
运行结果: