html tables & inline styles

前端 未结 2 1843
孤独总比滥情好
孤独总比滥情好 2021-01-14 02:42

I don\'t have a lot of experience with HTML tables and in-line CSS, but I\'m trying to create an HTML email signature. Ideally, I\'d like to have a small image on the left,

相关标签:
2条回答
  • 2021-01-14 03:16

    Forget float, margin and html 3/5. The mail is very obsolete. You need do all with table. One line = one table. You need margin or padding ? Do another column.

    Codepen

    Example : i need one line with 1 One Picture of 40*40 2 One margin of 10 px 3 One text of 400px

    I start my line :

    <table style=" background-repeat:no-repeat; width:450px;margin:0;" cellpadding="0" cellspacing="0" border="0">
       <tr style="height:40px; width:450px; margin:0;">
         <td style="height:40px; width:40px; margin:0;">
            <img src="" style="width=40px;height40;margin:0;display:block"
         </td>
         <td style="height:40px; width:10px; margin:0;">        
         </td>
         <td style="height:40px; width:400px; margin:0;">
         <p style=" margin:0;"> my text   </p>
         </td>
       </tr>
    </table>
    
    0 讨论(0)
  • 2021-01-14 03:19

    This should do the trick:

    <table width="400" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="50" height="40" valign="top" rowspan="3">
          <img alt="" src="" width="40" height="40" style="margin: 0; border: 0; padding: 0; display: block;">
        </td>
        <td width="350" height="40" style="font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: #000000;">
    <a href="" style="color: #D31145; font-weight: bold; text-decoration: none;">LAST FIRST</a><br>
    REALTOR | P 123.456.789
        </td>
      </tr>
      <tr>
        <td width="350" height="70" valign="bottom" style="font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: #000000;">
    <img alt="" src="" width="200" height="60" style="margin: 0; border: 0; padding: 0; display: block;">
        </td>
      </tr>
      <tr>
        <td width="350" height="20" valign="bottom" style="font-family: Helvetica, Arial, sans-serif; font-size: 10px; color: #000000;">
    all your minor text here | all your minor text here | all your minor text here
        </td>
      </tr>
    </table>
    

    UPDATE: Adjusted code per the comments:

    After viewing your jsFiddle, an important thing to note about tables is that table cell widths in each additional row all have to be the same width as the first, and all cells must add to the total width of your table.

    Here is an example that will NOT WORK:

    <table width="600" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="200" bgcolor="#252525">&nbsp;
        </td>
        <td width="400" bgcolor="#454545">&nbsp;
        </td>
      </tr>
      <tr>
        <td width="300" bgcolor="#252525">&nbsp;
        </td>
        <td width="300" bgcolor="#454545">&nbsp;
        </td>
      </tr>
    </table>
    

    Although the 2nd row does add up to 600, it (and any additional rows) must have the same 200-400 split as the first row, unless you are using colspans. If you use a colspan, you could have one row, but it needs to have the same width as the cells it is spanning, so this works:

    <table width="600" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="200" bgcolor="#252525">&nbsp;
        </td>
        <td width="400" bgcolor="#454545">&nbsp;
        </td>
      </tr>
      <tr>
        <td width="600" colspan="2" bgcolor="#353535">&nbsp;
        </td>
      </tr>
    </table>
    

    Not a full tutorial, but I hope that helps steer you in the right direction in the future.

    Here is the code you are after:

    <table width="900" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="57" height="43" valign="top" rowspan="2">
          <img alt="Rashel Adragna" src="http://zoparealtygroup.com/wp-content/uploads/2013/10/sig_head.png" width="47" height="43" style="margin: 0; border: 0; padding: 0; display: block;">
        </td>
        <td width="843" height="43" style="font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: #000000;">
    <a href="" style="color: #D31145; font-weight: bold; text-decoration: none;">RASHEL ADRAGNA</a><br>
    REALTOR | P 855.900.24KW
        </td>
      </tr>
      <tr>
        <td width="843" height="64" valign="bottom" style="font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: #000000;">
    <img alt="Zopa Realty Group logo" src="http://zoparealtygroup.com/wp-content/uploads/2013/10/sig_logo.png" width="177" height="54" style="margin: 0; border: 0; padding: 0; display: block;">
        </td>
      </tr>
      <tr>
        <td width="843" colspan="2" height="20" valign="bottom" align="center" style="font-family: Helvetica, Arial, sans-serif; font-size: 10px; color: #000000;">
    all your minor text here | all your minor text here | all your minor text here
        </td>
      </tr>
    </table>
    

    You'll note that I've added an extra 10px to some of your table cells. This in combination with align/valigns act as padding between your cells. It is a clever way to aviod actually having to add padding, margins or empty padding cells.

    0 讨论(0)
提交回复
热议问题