二、实践:
1.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css" media="screen"> *{ margin: 0; padding: 0; } body>div{ border:1px solid #ccc; margin:20px; padding:10px; } div>div{ background-color: #123589; border:1px solid #a6f5f3; width:100px; height:100px; text-align: center; line-height: 100px; } .box{ display: -moz-box; display: -webkit-box; } .inline-box{ display:-moz-inline-box; } </style> </head> <body> <div class="box"> <div>A</div> <div>B</div> <div>C</div> <div>D</div> </div> <div class="inline-box"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> </div> </body> </html>2.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css" media="screen"> *{ margin:0; padding: 0; } body>div{ border:1px solid #0055cc; margin: 20px; padding: 10px; } div > div{ border:1px crimson #f36; } .box{ display:-moz-box; display: -webkit-box; display: box; } .box-horizontal{ -moz-box-orient:horizontal; -webkit-box-orient: horizontal; box-orient:horizontal; } .box-vertical{ -moz-box-orient: vertical; -webkit-box-orient: vertical; box-orient:vertical; } .box-inline-axis{ -moz-box-orient: inline-axis; -webkit-box-orient: inline-axis; box-orident:inline-axis; } .box-block-axis{ -moz-box-orient: block-axis; -webkit-box-orient: block-axis; box-orident:block-axis; } </style> </head> <body> <div class="box box-horizontal"> <div>A</div> <div>B</div> <div>C</div> <div>D</div> </div> <div class="box box-vertical"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> </div> <div class="box box-inline-axis"> <div>1-1</div> <div>2-1</div> <div>3-1</div> <div>4-1</div> </div> <div class="box box-block-axis"> <div>1a</div> <div>2a</div> <div>3a</div> <div>4a</div> </div> </body> </html>3.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css" media="screen"> *{ margin:0; padding: 0; } body>div{ border:1px solid #0055cc; margin: 20px; padding: 10px; } div > div{ border:1px crimson #f36; } .box{ display:-moz-box; display: -webkit-box; display: box; } .box-horizontal{ -moz-box-orient:horizontal; -webkit-box-orient: horizontal; box-orient:horizontal; width:250px; } .box-vertical{ -moz-box-orient: vertical; -webkit-box-orient: vertical; box-orient:vertical; height:250px; } .box-direction-reverse{ -moz-box-direction: reverse; -webkit-box-direction: reverse; box-direction:reverse; } </style> </head> <body> <div class="box box-horizontal"> <div>A</div> <div>B</div> <div>C</div> <div>D</div> </div> <div class="box box-vertical box-direction-reverse"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> </div> <div class="box box-inline-axis"> <div>1-1</div> <div>2-1</div> <div>3-1</div> <div>4-1</div> </div> <div class="box box-block-axis box-direction-reverse"> <div>1a</div> <div>2a</div> <div>3a</div> <div>4a</div> </div> </body> </html>4.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css" media="screen"> *{ margin: 0; padding: 0; } body>div{ border: 1px solid #0066cc; margin: 10px; width: 200px; height: 200px; } div > div{ border: 1px crimson #f36; padding: 10px; } .box{ display: -moz-box; display: -webit-box; display: box; -moz-box-pack: start; -webkit-box-pack: start; box-pack: start; -moz-box-align: start; -webkit-box-align:start; box-align:start; box-pack:start; -moz-box-lines:multiple; -webkit-box-lines:multiple; box-lines:multiple; } .box-horizontal{ -moz-box-orient: horizontal; -webkit-box-orient:horizontal; box-orient:horizontal } .box-vertical{ -moz-box-orient:vertical; -webkit-box-orient:vertical; box-orient:vertical; } </style> </head> <body> <div class="box box-horizontal"> <div>A</div> <div>B</div> <div>C</div> <div>D</div> <div>E</div> <div>F</div> <div>G</div> <div>H</div> <div>1</div> <div>2</div> <div>3</div> </div> <div class="box box-vertical"> <div>A1</div> <div>B1</div> <div>C1</div> <div>D1</div> <div>E1</div> <div>F1</div> <div>G1</div> <div>H1</div> <div>11</div> <div>21</div> <div>31</div> </div> </body> </html>5.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css" media="screen"> .box{ width: 500px; height: 200px; margin:20px; border:1px solid #ccc; font-size:20px; font-weight: bold; color:#fff; } .box-item{ background-color: #6bb2ff; } .box,.box3 > div{ padding: 10px; } .box div:nth-child(1){ background-color: #819321; line-height: 50px; } .box div:nth-child(2){ background-color: #168929; line-height: 50px; } .box div:nth-child(3){ background-color: #197332; line-height: 50px; } .box div:nth-child(4){ background-color: #390289; } .box div:nth-child(5){ background-color: #702356; } .box{ display: -webkit-box; display:-moz-box; display:box; -webkit-box-align: start; -moz-box-align: start; box-align:start; -webkit-box-pack:start; -moz-box-pack:start; box-pack:start; } .box-orient-vertical{ -webkit-box-orient: vertical; -moz-box-orient: vertical; box-orient:vertical; height: 400px; } .box3{ display: -webkit-box; display:-moz-box; display:box; -webkit-box-align: start; -moz-box-align: start; box-align:start; -webkit-box-pack:end; -moz-box-pack:end; box-pack:end; width:100px; } .box4{ display: -webkit-box; display:-moz-box; display:box; -webkit-box-align: start; -moz-box-align: start; box-align:start; -webkit-box-pack:center; -moz-box-pack:center; box-pack:center; background-color: #238692; width:100px; } .box5{ display: -webkit-box; display:-moz-box; display:box; -webkit-box-align: start; -moz-box-align: start; box-align:start; -webkit-box-pack:justify; -moz-box-pack:justify; box-pack:justify; background-color: #8f8f8f; width:100px; } </style> </head> <body> <div class="box box-pack-start"> <div class="box-item">box~~1</div> <div class="box-item">box~~2</div> <div class="box-item">box~~3</div> <div class="box-item">box~~4</div> <div class="box-item">box~~5</div> </div> <div class="box box-pack-start box-orient-vertical"> <div class="box-item">~~1</div> <div class="box-item">~~2</div> <div class="box-item">~~3</div> <div class="box-item">~~4</div> <div class="box-item">~~5</div> </div> <div class="box3 box-pack-start box-orient-vertical"> <div class="box-item">~~1</div> <div class="box-item">~~2</div> <div class="box-item">~~3</div> <div class="box-item">~~4</div> <div class="box-item">~~5</div> </div> <div class="box4 box-pack-start box-orient-vertical"> <div class="box-item">~~1</div> <div class="box-item">~~2</div> <div class="box-item">~~3</div> <div class="box-item">~~4</div> <div class="box-item">~~5</div> </div> <div class="box5 box-pack-start box-orient-vertical"> <div class="box-item">~~1</div> <div class="box-item">~~2</div> <div class="box-item">~~3</div> <div class="box-item">~~4</div> <div class="box-item">~~5</div> </div> </body> </html>6.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css" media="screen"> *{ margin: 0; padding: 0; } body{ color:#8f8f8f; font-size:20px; } .box-flex{ width:910px; background: gray; margin:100px; display:-webkit-box; display:-moz-box; display:box; } .box-flex p:first-child{ background: darkgreen; -moz-box-flex:1; -webkit-box-flex:1; box-flex:1; } .box-flex p:last-child{ background: orange; -moz-box-flex:2; -webkit-box-flex:2; box-flex:2; } </style> </head> <body> <div class="box-flex"> <p> 我想吃一盘红烧肉~ </p> <p> 没有红烧肉,排骨我也很想吃~ </p> </div> </body> </html>