【问题标题】:Insert Image in a <td> with different resolution将图像插入具有不同分辨率的 <td>
【发布时间】:2013-07-04 08:25:06
【问题描述】:

我有一个有 3 行的表,其中之一就是这个:

  <tr>
  <td>Logo Programma</td>
  <td>Giorno</td>
  <td>Giorno</td>
  <td>Put the image here</td>
  </tr>

现在我想添加一张图片,我已经使用了这样的标签

<td><img src="image.jpg" alt=""></td>

分辨率是 788x592 但我不想使用 788x592 像素,它会很大! 所以我想保持比例但分辨率较低。

【问题讨论】:

  • 你能试试 JSFiddle 吗?
  • 你可以改变你的图片大小&lt;img width="100" height="100"/&gt;

标签: html image resolution html-table


【解决方案1】:

使用img标签中的heightwidth,像这样:

<img src="image.jpg" width="100" height="200" alt="">

编辑如果只知道一个维度,您可以省略第二次测量,图像将相应地scale

【讨论】:

  • 是的,当您替换实数时会。
【解决方案2】:

要在设置新尺寸的同时保持图像的比例,请执行以下操作:

<td><img src="image.jpg" alt="" style="width:200px; height:auto;"></td>

这会将宽度设置为200px,高度将自动调整以保持比例。您还可以计算应为的高度并将其添加为固定数字。

【讨论】:

  • 谢谢!这就是我想要的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-25
  • 2012-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多