[英]how to fit image inside TD of HTML table
I am displaying an image inside TD using: 我正在使用以下内容在TD中显示图像:
But image seems to be taking larger width than the width defined for the TD. 但是图像似乎比TD定义的宽度更宽。
Please provide me some solution. 请给我一些解决方案。
CSS solution CSS解决方案
td img {
max-width:100%;
height:auto;
}
You could try this: 你可以试试这个:
If you want ALL <td>
's to have images: 如果你想要所有
<td>
的图像:
HTML: HTML:
<table class="imagetable">
<tr>
<td>Hey wat up</td>
</tr>
</table>
CSS: CSS:
.tableimage td {
background-image:url('http://example.com/image.jpg');
background-size: 100% 100%;
}
If you just want ONE <td>
to have an image 如果你只想让ONE
<td>
拥有一张图片
HTML: HTML:
<td class="image">Hey wat up</td>
CSS: CSS:
.image {
background-image:url('http://example.com/image.jpg');
background-size: 100% 100%;
}
Hope this helps :) 希望这可以帮助 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.