赞
踩
上图说明如下:
flex-direction: row | row-reverse | column | column-reverse;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> .content1 { width: 200px; height: 200px; border: 1px solid #c3c3c3; display: flex; flex-direction: row; /*默认值,行对齐,主轴起点与终点相同*/ } .content2 { width: 200px; height: 200px; border: 1px solid #c3c3c3; display: flex; flex-direction: row-reverse; /*行对齐,主轴起点与终点相反*/ } .content3 { width: 200px; height: 200px; border: 1px solid #c3c3c3; display: flex; flex-direction: column; /*列对齐,主轴起点与终点相同*/ } .content4 { width: 200px; height: 200px; border: 1px solid #c3c3c3; display: flex; flex-direction: column-reverse; /*列对齐,主轴起点与终点相反*/ } .box { width: 50px; height: 50px; color: black; } </style> </head> <body> <div class="content1"> <div class="box" style="background-color:#FFE5B9;">A</div> <div class="box" style="background-color:#EFF8FF;">B</div> <div class="box" style="background-color:#C9CBFF;">C</div> </div> <div class="content2"> <div class="box" style="background-color:#FFE5B9;">A</div> <div class="box" style="background-color:#EFF8FF;">B</div> <div class="box" style="background-color:#C9CBFF;">C</div> </div> <div class="content3"> <div class="box" style="background-color:#FFE5B9;">A</div> <div class="box" style="background-color:#EFF8FF;">B</div> <div class="box" style="background-color:#C9CBFF;">C</div> </div> <div class="content4"> <div class="box" style="background-color:#FFE5B9;">A</div> <div class="box" style="background-color:#EFF8FF;">B</div> <div class="box" style="background-color:#C9CBFF;">C</div> </div> </body> </html>
flex-wrap: nowrap|wrap|wrap-reverse|initial|inherit;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> div { width: 100px; height: 100px; color: black; } #content { width: 240px; height: 300px; background-color: white; display: flex; flex-wrap: wrap-reverse; } .item1 { background-color: #ffe5b9; } .item2 { background-color: #eff8ff; } .item3 { background-color: #c9cbff; } </style> </head> <body> <div id="content"> <div class="item1">1</div> <div class="item2">2</div> <div class="item3">3</div> </div> </body> </html>
align-items: flex-start | flex-end | center | baseline | stretch;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> div { width: 100px; color: black; } #content { width: 240px; height: 300px; background-color: white; display: flex; align-items: stretch; } .item1 { background-color: #ffe5b9; } .item2 { background-color: #eff8ff; } .item3 { background-color: #c9cbff; } </style> </head> <body> <div id="content"> <div class="item1">1</div> <div class="item2">2</div> <div class="item3">3</div> </div> </body> </html>
align-content: flex-start | flex-end | center | space-between | space-around |
stretch;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> div { width: 60px; color: black; } #content { width: 300px; height: 300px; background-color: antiquewhite; display: flex; flex-wrap: wrap; align-content: stretch; } .left { background-color: gray; } .center { background-color: silver; } .right { background-color: darkgray; } </style> </head> <body> <div id="content"> <div class="left">div1块</div> <div class="center">div2块</div> <div class="right">div3块</div> <div class="left">div4块</div> <div class="center">div5块</div> <div class="right">div6块</div> <div class="left">div7块</div> <div class="center">div8块</div> <div class="right">div9块</div> <div class="left">div10块</div> <div class="center">div11块</div> <div class="right">div12块</div> </div> </body> </html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。