表单元格与图像和文本对齐

时间:2018-11-22 09:35:37

标签: html css html-table alignment

<table style="width:100%">
 <tr>
  <th>type</th>
  <th>descritpion</th> 
 </tr>
<tr>
 <td><p><img src="mail.ping" style="width: 30px;"></p>
  <span>type-cedit ad=nd debit and shopping</td>
 <td>description</td>
  </tr>
</table>

enter image description here

上图是显示表数据。当图像和文本在表格单元格内对齐时。 当文本较小时,这可以正常工作。但是当文本大时。文字出现在图片下方。

在上图中,如果长度很大,我需要使“购物”工作低于“类型”。文字不应出现在图像下方。我该如何解决此对齐问题

1 个答案:

答案 0 :(得分:0)

应用display:inline-blockfloat:left可以将两者对齐

.divin{
display:inline-block;}
<table style="width:100%">
 <tr>
  <th>type</th>
  <th>descritpion</th> 
 </tr>
<tr>
 <td><p class="divin"><img src="https://www.google.co.in/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" style="width: 30px;"></p>
 <span class="divin">type-cedit ad=nd debit and shopping</span></td>
 <td>description</td>
  </tr>
</table>