将div设置为显示的问题:table-cell;

时间:2011-09-17 00:28:04

标签: html css

<!DOCTYPE html>
<html>
<head>
<style>
* {margin:0;padding:0;outline:0;border:0;}
aside {background:red;width:40%;display:table-cell;}
.two {width:40%;background:blue;display:table-cell;}
.one {width:30%;background:green;display:table-cell;}
#wrapper {display:table;width:100%;}
</style>
</head>
<body>
<div id="wrapper">
<aside>
<div style="height: 100px; width: 100px; border: 2px solid orange;">

</div><!-- / -->
</aside>
<section class="two">
Text
</section>
<section class="one">
Text
</section>
</div>
</body>
</html>

这是代码的JSFiddle:http://jsfiddle.net/jtmkrueger/Aza47/

在这种情况下,如何让单元格中的内容始终被置于顶部?请注意,第二个和第三个框中的“文本”被按下...

1 个答案:

答案 0 :(得分:4)

使用vertical-align: top;样式。

请参阅updated jsfiddle