将图像移动到单元格的顶部

时间:2016-05-30 18:04:23

标签: html css web

我想将图像放在单元格顶部,但我无法向上移动,有网络照片

Image

我的CSS

#animes {
  width: 130px;
  height: 100px;
  display: block;
  padding-left: 10px;
  padding-right: 10px;
  padding-top: -50px;
}

1 个答案:

答案 0 :(得分:-1)

将valign =“top”添加到单元格。就像在这个fiddle

中一样

HTML:

<table cellspacing="0" cellpadding="0" border="1">
  <tr>
    <td valign="top"><img src="https://www.smallbusinesssaturdayuk.com/Images/Small-Business-Saturday-UK-Google-Plus.gif"></td>
    <td></td>
  <tr>
</table>

CSS:

table{
  width: 500px;
  height: 300px;
}
/* If you want it done from CSS remove the valign and add in your css the following:  */

td { vertical-align: top; }

以下是fiddle with vertical-align