代码之家  ›  专栏  ›  技术社区  ›  xyz

在电子邮件中嵌入html表

  •  0
  • xyz  · 技术社区  · 8 年前

    我正在尝试将html表嵌入到我从其中一个发送的电子邮件中我正在构建的应用程序就是我正在尝试的

    <table width="400" style="border:1px solid #333">
      <tr> 
         <th>Isolate Lots</th>
         <th>Identification</th>
      </tr>  
      #foreach( $sample in $SAMPLES)
      #if($EXPSAMPLES[$foreach.index].getData("jax_trait_isolateIdentification") !="Unidentified")  
      <tr>
      <td>$LOTS[$foreach.index].name </td>
      <td>$EXPSAMPLES[$foreach.index].getData("jax_trait_isolateIdentification") 
      </td>
      </tr>
      #end #end
     </table>
    

    电子邮件中的表如下所示 enter image description here

    如何将单元格中的所有内容放入表中并对齐它们。

    编辑后

    enter image description here

    3 回复  |  直到 8 年前
        1
  •  1
  •   Ruslan    8 年前

    尝试设置 style="vertical-align: middle" 对于每个单元格(自 valign="middle" 已过时)。

    <table style="border-collapse: collapse; width: 400px">
      <tr>
        <th style="border: 1px solid  #333; vertical-align: middle">Isolate Lots</th>
        <th style="border: 1px solid  #333; vertical-align: middle">Identification</th>
      </tr>
      <tr>
        <td style="border: 1px solid  #333; vertical-align: middle">name</td>
        <td style="border: 1px solid  #333; vertical-align: middle">jax_trait_isolateIdentification</td>
      </tr>
    </table>

    Upd:添加边框

        2
  •  0
  •   V1t0r    8 年前

    您没有指定您所指的对齐方式,因此我建议您在单元格中添加“align=“center”样式,以防需要居中对齐。

    <table width="400" style="border:1px solid #333">
      <tr> 
         <th align="center">Isolate Lots</th>
         <th align="center">Identification</th>
      </tr>  
      #foreach( $sample in $SAMPLES)
      #if($EXPSAMPLES[$foreach.index].getData("jax_trait_isolateIdentification") !="Unidentified")
      <tr>
      <td align="center">$LOTS[$foreach.index].name</td>
      <td align="center">$EXPSAMPLES[$foreach.index].getData("jax_trait_isolateIdentification")
      </td>
      </tr>
    #end #end
     </table>
    
        3
  •  0
  •   Varsha    8 年前

    你的代码是正确的也许你应该试试这个 我只是改变一下你桌子的样式 希望它能起作用。在此处输入代码

    <table width="400" border='1px' style='text-align:center'>
      <tr> 
         <th>Isolate Lots</th>
         <th>Identification</th>
      </tr>  
      #foreach( $sample in $SAMPLES)
      #if($EXPSAMPLES[$foreach.index].getData("jax_trait_isolateIdentification") !="Unidentified")  
      <tr>
      <td>$LOTS[$foreach.index].name </td>
      <td>$EXPSAMPLES[$foreach.index].getData("jax_trait_isolateIdentification") 
      </td>
      </tr>
      #end #end
     </table>