HTML 表格对齐图像和文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10133595/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 23:45:10  来源:igfitidea点击:

HTML Table align images and text

html

提问by Ricardo Ribeiro

In a sample article I added a html table widh 2 columns, left column for images and right column for image descriptions.

在示例文章中,我添加了一个 html 表,宽度为 2 列,左列用于图像,右列用于图像描述。

The problem is, the text description on the right column is below the images, it′s like the images are forcing the text to break into another line.

问题是,右栏的文字描述在图片的下方,就像图片强迫文字换行一样。

this is a sample code as I used:

这是我使用的示例代码:

<table>
<tr>
<td>Image.jpg</td>
<td>Image.jpg description</td>
</tr>
<tr>
<td>Image2.jpg</td>
<td>Image2.jpg description</td>
</tr>
</table>

You can see the problem here On this page

您可以在此页面上看到问题

回答by kpotehin

You just have to add style="vertical-align:top"to td

你只需要添加style="vertical-align:top"td

Or vertical-align:middleif you'd like to position the text in the middle of the row

或者,vertical-align:middle如果您想将文本放置在行的中间

回答by Marc

Try this CSS in the text <TD>:

在文本中试试这个 CSS <TD>

vertical-align:top;

i.e.:

IE:

<td style="vertical-align:top;">
   Trio: Quaisquer três cartas do mesmo valor. Este exemplo ...
</td>

回答by Rachel Arts

So to understand you want the photo and the text to align correct? Can you use a valign attribute?

那么要了解您希望照片和文字正确对齐吗?您可以使用 valign 属性吗?

<table>
<tr>
 <td valign="top">January</td>
 <td valign="top">0</td>
</tr>
<tr> 
<td valign="bottom">February</td>
 <td valign="bottom"></td>
   </tr>
</table>

Top, Bottom and Center should be used depending on how you want it to align.

应根据您希望如何对齐使用顶部、底部和中心。