首页 > Web开发 > 详细

纯css实现两列等高

时间:2016-02-24 14:02:00      阅读:238      评论:0      收藏:0      [点我收藏+]
<!doctype html>
<html>
<head>
<meta />
<title>Title</title>
<style type="text/css">  
*{ margin:0; padding:0;}
.wrap { margin: 0 auto; width: 600px; clear: both; overflow: hidden; } 
.left {margin-bottom: -8000px; padding-bottom: 8000px; width: 300px; float: left; background: #f00; }
.right {margin-bottom: -8000px; padding-bottom: 8000px; width: 200px; float: right; background: #0f0; }
</style>
  
</head>

<body>
<div class="wrap">
    <div class="left">
        <p>text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </p> 
    </div>
    <div class="right">
        <p>text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text t text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </p>
    </div>
</div>
</body>
</html>

 

原理: 父盒子包含两个div,这两个div的不用写高度,而是都写上padding-bottom: 10000px;margin-bottom: -10000px;然后给父盒子加是overflow:hidden;如果填充这两个div,较高的那个div的高度将决定父盒子的高度。

纯css实现两列等高

原文:http://www.cnblogs.com/darkterror/p/5212613.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!