使用Float
<!--已知兩個div的寬度使用[Float]使兩個DIV同行!注:float使用后需要清除;所以多寫一個div--> <div style="width: 300px; height: 200px; border: 1px solid #4cff00;"> <div style="width: 70%; height: 50%; float: left; background-color: red;">我是第一個div</div> <div style="width: 30%; height: 50%; float: right; background-color: yellow;">我是第二個div</div> <div style="clear: both;"></div> </div>
網頁效果: