如何使用div而不是纯css中的表格实现100%的高度效果?
我通常创建一个包含div(模拟表行),然后为特定列创建div(模拟表数据) 这允许在容器中绝对定位元素。然后,我们可以利用绝对定位的一些优点来拉伸列div:如何使用div而不是纯css中的表格实现100%的高度效果?,css,Css,我通常创建一个包含div(模拟表行),然后为特定列创建div(模拟表数据) 这允许在容器中绝对定位元素。然后,我们可以利用绝对定位的一些优点来拉伸列div: .column { position: absolute; top: 0; bottom: 0; } 然后,您需要将左列放在左侧,将右列放在右侧: .left-column { left: 0; } .right-column { right: 0; } 其余的(造型)由你决定,我认为应该这样做 编辑:概念证明 我编写了以下概念验证代码
.column { position: absolute; top: 0; bottom: 0; }
然后,您需要将左列放在左侧,将右列放在右侧:
.left-column { left: 0; }
.right-column { right: 0; }
其余的(造型)由你决定,我认为应该这样做
编辑:概念证明
我编写了以下概念验证代码:
<html>
<head>
<style type="text/css">
.container { height: 200px; width: 200px; position: relative; border: 5px solid red; }
.left-column { width: 100px; background-color: blue; left: 0; }
.right-column { width: 100px; background-color: yellow; right: 0; }
.column { position: absolute; top: 0; bottom: 0; }
</style>
</head>
<body>
<div class="container">
<div class="left-column column"></div>
<div class="right-column column"></div>
</div>
</body>
</html>
.container{高度:200px;宽度:200px;位置:相对;边框:5px实心红色;}
.left列{宽度:100px;背景色:蓝色;左侧:0;}
.右列{宽度:100px;背景色:黄色;右:0;}
.column{位置:绝对;顶部:0;底部:0;}
其呈现为:
我希望这会有所帮助。我通常创建一个包含div(模拟表行),然后为特定列创建div(模拟表数据) 这允许在容器中绝对定位元素。然后,我们可以利用绝对定位的一些优点来拉伸列div:
.column { position: absolute; top: 0; bottom: 0; }
然后,您需要将左列放在左侧,将右列放在右侧:
.left-column { left: 0; }
.right-column { right: 0; }
其余的(造型)由你决定,我认为应该这样做
编辑:概念证明
我编写了以下概念验证代码:
<html>
<head>
<style type="text/css">
.container { height: 200px; width: 200px; position: relative; border: 5px solid red; }
.left-column { width: 100px; background-color: blue; left: 0; }
.right-column { width: 100px; background-color: yellow; right: 0; }
.column { position: absolute; top: 0; bottom: 0; }
</style>
</head>
<body>
<div class="container">
<div class="left-column column"></div>
<div class="right-column column"></div>
</div>
</body>
</html>
.container{高度:200px;宽度:200px;位置:相对;边框:5px实心红色;}
.left列{宽度:100px;背景色:蓝色;左侧:0;}
.右列{宽度:100px;背景色:黄色;右:0;}
.column{位置:绝对;顶部:0;底部:0;}
其呈现为:
我希望这能有所帮助。这是一个很好的例子,展示了如何以css的方式实现全高和等高列
这是一个很好的例子,展示了如何以css方式创建全高和等高列
我期待着一场tables vs.CSS firestorm!我期待着一场表格大战CSS firestorm!