【问题标题】:Move an image to a top of a cell将图像移动到单元格顶部
【发布时间】:2016-09-28 15:00:03
【问题描述】:

我想把图片放在单元格的顶部,但是我不能再往上移动了,有网络的照片

我的 CSS

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

【问题讨论】:

  • 是的,祝你好运......
  • 你需要更具描述性,我什至无法说出你在问什么。也许显示一些您尝试过的示例代码。如果您希望得到帮助,您必须在这个问题上付出更多的努力。
  • 我们都处于紧急状态,伙计。
  • 我们可以在 JS Fiddle 中看到问题吗?

标签: html css web


【解决方案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

【讨论】:

  • 请注意,valign 在 HTML5 中已弃用。改用 CSS。
  • 如果你想要 HTML5,那么只需使用:td { vertical-align: top; }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-22
  • 2022-07-11
  • 1970-01-01
相关资源
最近更新 更多