經典佈局案例(三):html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>CSS佈局</title> </head> <body> <div style="height: 400px;width: 200px;float: left"></div> <div style="height: 400px;width: 200px;float: left;clear: both"></div> <div style="height: 800px;overflow: hidden"></div> </body> </html>
上述代碼定義了三個div塊,用到了float浮動屬性、overflow屬性和clear屬性。佈局
頁面效果以下:spa
其中紅色和藍色div塊爲定寬綠色不定寬。 code
轉載自本人ITeye連接:http://xiaozhuang0706.iteye.com/blog/2263015htm