12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <!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: rgba(0,0,0,0.5);
- display: flex;
- }
- #div2{
- width: 200px;
- height: 200px;
- background: red;
- }
- #div3{
- height: 200px;
- background: blue;
- /* 占据剩余空间的一份 */
- flex: 1;
- }
- #div4{
- height: 200px;
- background: orange;
- flex: 2;
- }
- </style>
- </head>
- <body>
- <div id="div1">
- <div id="div2"></div>
- <div id="div3"></div>
- <div id="div4"></div>
- <!--
- flex-direction 属性定义容器要在哪个方向上堆叠 flex 项目。
- row 默认值。作为一行,水平地显示弹性项目。
- row-reverse 等同行,但方向相反。
- column 作为列,垂直地显示弹性项目。
- column-reverse 等同列,但方向相反。
- flex-wrap 属性规定是否应该对 flex 项目换行。
- nowrap 默认值。规定弹性项目不会换行。
- wrap 规定弹性项目会在需要时换行。
- wrap-reverse 规定弹性项目会在需要时换行,以反方向。
- justify-content 属性用于对齐 flex 项目:
- flex-start 默认值。项目位于容器的开头。
- flex-end 项目位于容器的结尾。
- center 项目位于容器中央。
- space-between 项目在行与行之间留有间隔。
- space-around 项目在行之前、行之间和行之后留有空间。
- align-items 属性用于垂直对齐 flex 项目。
- stretch 默认。项目被拉伸以适合容器。
- center 项目位于容器的中央。
- flex-start 项目位于容器的开头。
- flex-end 项目位于容器的末端。
- baseline 项目被定位到容器的基线。
- align-content 属性用于对齐弹性线。
- stretch 默认值。行拉伸以占据剩余空间。
- center 朝着弹性容器的中央对行打包。
- flex-start 朝着弹性容器的开头对行打包。
- flex-end 朝着弹性容器的结尾对行打包。
- space-between 行均匀分布在弹性容器中。
- space-around 行均匀分布在弹性容器中,两端各占一半。
- -->
- </div>
- </body>
- </html>
|