1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- #div1{
- height: 500px;
- background: #ccc;
- display: flex;
- }
- #div2{
- width: 200px;
- height: 200px;
- background: #ff0000;
- }
- #div3{
- width: 200px;
- height: 200px;
- background: #000;
- flex: 2;
- }
- #div4{
- width: 200px;
- height: 200px;
- background: blue;
- flex: 1;
- }
- </style>
- </head>
- <body>
- <div id="div1">
- <div id="div2"></div>
- <div id="div3"></div>
- <div id="div4"></div>
- </div>
- <!--
- 弹性盒模型
- display: flex
- wrap 值规定 flex 项目将在必要时进行换行
- nowrap 值规定将不对 flex 项目换行(默认)
- wrap-reverse 值规定如有必要,弹性项目将以相反的顺序换行
- flex-direction 属性
- column 值设置垂直堆叠 flex 项目(从上到下)
- column-reverse 值垂直堆叠 flex 项目(但从下到上)
- row 值水平堆叠 flex 项目(从左到右)
- row-reverse 值水平堆叠 flex 项目(但从右到左)
- justify-content: flex-start|flex-end|center|space-between|space-around
- center 值将 flex 项目在容器的中心对齐
- flex-start 值将 flex 项目在容器的开头对齐(默认)
- flex-end 值将 flex 项目在容器的末端对齐
- space-around 值显示行之前、之间和之后带有空格的 flex 项目
- space-between 值显示行之间有空格的 flex 项目
- align-items:flex-start|flex-end|center|space-between|space-around
- space-between 值显示的弹性线之间有相等的间距
- space-around 值显示弹性线在其之前、之间和之后带有空格
- stretch 值拉伸弹性线以占据剩余空间(默认)
- center 值在容器中间显示弹性线
- flex-start 值在容器开头显示弹性线
- flex-end 值在容器的末尾显示弹性线
- -->
- </body>
- </html>
|