[英]Alignement of image with table row
I am having problems with a cell in my table, one row table for now, that contains an image. 我的表格中有一个单元格,现在有一个行表,包含一个图像。 Whenever I put the image inside the cell, the row automatically goes from the top of the table to the center.
每当我将图像放入单元格内时,该行自动从表格顶部移动到中心。 I tried using v align in the row but the other content ends up looking stupid.
我尝试在行中使用v align但其他内容最终看起来很愚蠢。 Help please.
请帮助。 Also I made sure the cell is bigger than the image by sizing down the image.
此外,我通过调整图像大小来确保单元格大于图像。 Please help.
请帮忙。
Thank you 谢谢
<table width="710" bgcolor="white" height="600" align="center" cellpadding="10">
<tr>
<td width="100" height="150" align="center" valign="top">Home</td>
<td width="100" height="150" align="center">Food</td>
<td width="100" height="150" align="center">Hobbies</td>
<td width="100" height="150" align="center">Martin's Blog</td>
<td width="300" height="150" colspan="2" valign="top"><img src="yooo.gif" width="250"></td></tr>
<tr>
<td height="450"> </td> </tr>
</table>
Add to the 2nd row same amount of TD or use colspan. 添加相同数量的TD第二行或使用colspan。
valign="top"
works ok. valign="top"
工作正常。
A few things to note. 有几点需要注意。
you should close your <img>
tags like so: 你应该关闭你的
<img>
标签:
<img src="yooo.gif" width="250" />
note the /
at the end of the tag. 注意标签末尾的
/
。
EDIT Apologies, the <img>
tag only needs to be closed when using XHTML. 编辑道歉,
<img>
标签只需要在使用XHTML时关闭。 Reference 参考
Secondly the <tr>
is the row tag not the <td>
tag. 其次
<tr>
是行标记而不是<td>
标记。 You've only applied valign="top"
to one of your cells. 您只对其中一个单元格应用了
valign="top"
。 If you want the rest of the cells in that row to be aligned top you need to add the valign
to each cell. 如果您希望该行中的其余单元格对齐,则需要将
valign
添加到每个单元格。
Fiddle example here: http://jsfiddle.net/6E66m/ 这里的小提琴示例: http : //jsfiddle.net/6E66m/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.