這是div+css布局中經常會碰到的基礎問題,個人覺得采用背景圖填充的方法,還是比較簡單和切實可行的。最終效果。
CSS源代碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">_uacct = "UA-152060-1";urchinTracker();</script> <title>DIV+CSS排版中自適應高度的解決方法</title> <style type="text/css"> <!-- body{ background: #EDEDED; font-size: 70%; font-family: Arial, Helvetica, sans-serif; line-height: 130%; color: #666666; margin: 0; padding: 0; text-align: center; } #layout{ width: 760px; w/idth: 740px; margin: 10px auto; border: solid 10px #999999; border-bottom: solid 9px #999999; background: url(http://www.forest53.com/tutorials/images/sbg.gif) #FFFFFF repeat-y left; text-align: left; } #sidel{ float: left; width: 190px; } #sider{ float: right; width: 540px; } pre{ padding: 10px; margin: 0; } .clear{ background: #999999; clear: both; height: 1px; overflow: hidden; } p{ text-align: center; } --> </style></head><body><div id="layout"><div id="sider"><pre> body{ background: #EDEDED; font-size: 70%; font-family: Arial, Helvetica, sans-serif; line-height: 130%; color: #666666; margin: 0; padding: 0; text-align: center; } #layout{ width: 760px; w/idth: 740px; margin: 10px auto; border: solid 10px #999999; border-bottom: solid 9px #999999; background: url(bg.gif) #FFFFFF repeat-y left; text-align: left; } #sidel{ float: left; width: 190px; } #sider{ float: right; width: 540px; } pre{ padding: 10px; margin: 0; } .clear{ background: #999999; clear: both; height: 1px; overflow: hidden; }</pre></div><div id="sidel"><pre>#sidel{float: left;width: 190px;} #sider{float: right;width: 540px;} pre{padding: 10px;margin: 0;} .clear{background: #999999;clear: both;height: 1px;overflow: hidden;}</pre></div><div class="clear"></div></div><a href="http://www.jztop.com/web/">返回網頁陶吧</a></body></html>