1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title></title> 6 <style> 7 body{ 8 margin: 0; 9 } 10 .box{ 11 width: 500px; 12 } 13 .left{ 14 width: 200px; 15 height: 200px; 16 background-color: red; 17 float: left; 18 } 19 .right{ 20 width: 200px; 21 height: 200px; 22 background-color: blue; 23 <!--margin-left:200px 不建议这么写--> 24 } 25 </style> 26 <!-- 27 解决方案: 28 1、不建议这么写 29 2、用浮动解决 30 --> 31 </head> 32 <body> 33 <div class="box"> 34 <div class="left"></div> 35 <div class="right"></div> 36 </div> 37 </body> 38 </html>