clear为什么能实现自动高度
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>div自动高度</title> <style type="text/css"> .content{ margin: 0 auto; width: 1000px; border: 1px solid red; } #left{ width: 100px; height: 400px; border:1px solid blue; float: left; } #right{ width: 800px; height: 400px; border:1px solid green; float: left; } .clear{ clear: both; } </style> </head> <body> <div class="content"> <div id="left"> </div> <div id="right"> </div> <!-- <div class="clear"></div> --> </div> </body> </html>
.content{ margin: 0 auto; width: 1000px; float: left; border: 1px solid red; } #left{ width: 100px; height: 400px; border:1px solid blue; float: left; } #right{ width: 800px; height: 400px; border:1px solid green; float: left; }