html中单元格中文字如何靠顶部对齐?

html中单元格中文字如何靠顶部对齐?,第1张

可以借助属相valign来实现。实例如下:
<html>
<body>
<table border="1">
<tr>
<td width="100px" height="50px" valign="top">测试</td>
</tr>
</table>
</body>
</html>
效果如下:
补充知识:
valign的值有:top(顶对齐)
Middle(垂直居中)
bottom(底对齐)

添加一个align="left" valign="top"属性即可,其中align="left" 可以省略,默认为居左,具体代码如下:

<table width="500" height="120" border="1" >
  <tr>
    <td align="left" valign="top">表头01</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>表头02</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>表头03</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

jsp页面锁定表格的第一行不动的方法是通过js实现的。
1、html代码如下:
<div class="clscroll corner-header">
<table>
<tr>
<th> </th>
</tr>
</table>
</div>
<div class="clscroll column-headers" id="clscroll-column-headers">
<table>
<tr>
<th>Bus</th>
<th>Plane</th>
<th>Boat</th>
<th>Bicycle</th>
</tr>
</table>
</div>
<div class="clscroll row-headers" id="clscroll-row-headers">


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/13326576.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-15
下一篇 2023-07-15

发表评论

登录后才能评论

评论列表(0条)

保存