表格单元格基线与顶部

时间:2015-11-16 06:50:24

标签: html css vertical-alignment

我在表格单元格中使用了不同的垂直对齐值,发现了vertical-align:top和vertical-align:baseline的行为相同。 这是一个例子。

<!DOCTYPE html>
<style>
table, td, th {
    border: 1px solid black;
}

td#top {
    height: 50px;
    vertical-align: top;
}

td#baseline {
    height: 50px;
    vertical-align: baseline;
}
</style>
<body>

<table>
  <tr>
    <td id="top">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</td>
    <td id="top">Griffin</td>
    <td id="top">$100</td>
  </tr>
  <tr>
    <td id="baseline">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</td>
    <td id="baseline">Griffin</td>
    <td id="baseline">$150</td>
  </tr>
</table>

</body>

http://jsfiddle.net/d6vron9k/ 是否有垂直对齐:基线与vertical-align:top不同的情况? 如果是这样,有人会发布一个说明这个的例子吗?

3 个答案:

答案 0 :(得分:2)

  

是否存在vertical-align:baseline不同的情况   vertical-align:top?如果是这样,有人会发布一个示例说明   是什么?

不确定。见http://jsfiddle.net/d6vron9k/2。我刚刚添加了

td:first-child:first-letter {
    font-size: 3em;
}

(并更改了类的ID,因为它们并不是唯一的。)

您可以看到后一列中的文字在vertical-align: baseline的单元格中低于vertical-align: top的单元格。

答案 1 :(得分:0)

用于vertical-align: bottom;

就像这样

td#baseline {
    vertical-align: bottom;
}

答案 2 :(得分:0)