简体   繁体   English

CSS,在表格单元格中垂直对齐锚点

[英]CSS, vertical-align an anchor in table cell

I need to align the anchor tag in a table cell to top, the table cell contains a textarea. 我需要将表格单元格中的锚标记对齐到顶部,表格单元格包含一个textarea。 My code is as below but the anchor tag is align to bottom of the textarea. 我的代码如下,但锚标记是对齐到文本区域的底部。

<style>
td {
  border:#777 1px solid; vertical-align:top;
}

textarea {
  height:100px; width:300px;
}
</style>

<table>
  <tr>
    <td>Message:</td>
    <td>
      <textarea></textarea>
      <a href="javascript:" title="Required">*</a>
    </td>
  </tr>
</table>

How to vertical-align that anchor tag to top of the cell? 如何将锚标签垂直对齐到单元格的顶部?

在此处输入图片说明

Give that anchor a vertical-alignment of top as well: 也使该锚点与顶部垂直对齐:

td a {
    vertical-align: top;
}
<table>
<tr>
<td>Message:</td>
<td>
  <textarea></textarea>
 </td>
<td> <a href="javascript:" title="Required">*</a></td>
</tr>
</table>

By default, Textarea used to push the near element down to be in same line 默认情况下, Textarea用于将Near元素向下推至同一行

a {
vertical-align: top;
}

Check this JSFiddle 检查这个JSFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM