神一样的布局——等高布局

copyFrom====〉
http://www.cnblogs.com/2050/archive/2012/07/31/2616460.html

<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>高度自适应布局</title> <style> body{ padding:0; margin:0; color:#f00;} .container{ margin:0 auto; width:600px; border:3px solid #00C; overflow:hidden; /*这个超出隐藏的声明在IE6里不写也是可以的*/ } .left{ float:left; width:150px; background:#B0B0B0; padding-bottom:2000px; margin-bottom:-2000px; } .right{ float:left; width:450px; background:#6CC; padding-bottom:2000px; margin-bottom:-2000px; } </style> </head> <body> <div class="container"> <div class="left">我是left</div> <div class="right">我是right<br><br><br>现在我的高度比left高,但left用它的padding-bottom补偿了这部分高度</div> <div style="clear:both"></div> </div> </body> </html>
//PS因为我们padding不可能使用负的,所以padding-bottom:为正,margin-bottom为负的

  

posted @ 2014-05-22 10:33  方方和圆圆  阅读(247)  评论(1编辑  收藏  举报

再过一百年, 我会在哪里?