两列布局左右高度一致,但要自动
两列布局,右侧的高度是自动的,左侧内容较少,要做成和右侧一样的高度,除了position:absolute之外还有没有其他的办法?
两列布局,右侧的高度是自动的,左侧内容较少,要做成和右侧一样的高度,除了position:absolute之外还有没有其他的办法?
2015-12-17
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>等高列布局</title>
<style>
*{margin: 0;padding: 0;}
.row{
display: table-row;
}
.cell{
display: table-cell;
}
.left{
width: 200px;
height: 300px;
background: red;
}
.right{
width: 300px;
/*右边的div并没有设置height,但是他的高度会自动的等于 .left的高度,即300px*/
background: green;
}
</style>
</head>
<body>
<div class="row">
<div class="cell left"></div>
<div class="cell right"></div>
</div>
</body>
</html>举报