Html 将图像与表格单元格的顶部对齐
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14238153/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Aligning image to the top of a table cell
提问by niGeLL
I'm designing a wordpress page inside of the wordpress editor, and I can't figure out how to get the grey image placeholder to align to the top of the table cell. As long as the text in the left cell doesn't go below the grey image, everything is fine. But as soon as the text gets below the bottom of the image, the image pushes down. Here's the code:
我正在 wordpress 编辑器中设计一个 wordpress 页面,但我不知道如何让灰色图像占位符与表格单元格的顶部对齐。只要左侧单元格中的文本不低于灰色图像,一切都很好。但是一旦文本低于图像底部,图像就会向下推。这是代码:
<table border="1">
<tbody>
<tr>
<td style="vertical-align: top;">
<img class="alignleft size-full wp-image-71" alt="webi" src="#"
width="437" height="114" />
<p>
SOME TEXT
</p>
</td>
<td style="width: 355px;">
<img class="alignright size-full wp-image-61" alt="palvelut_kuvapaikka"
src="#"
align="top" width="355" height="355" />
</td>
</tr>
</tbody>
</table>
回答by Christian
Just set the vertical-align: top
property on the right td
as well?
也只是将vertical-align: top
属性设置在右侧td
?
回答by Chanckjh
to align it to the top in a table you need to use in css: vertical-align: top
要将其与您需要在 css 中使用的表格的顶部对齐: vertical-align: top