如何让bgcolored td's拉伸到适合

时间:2013-10-25 16:08:33

标签: html css email

处理需要在Outlook 365中运行的模板。不确定为什么橙色线未伸展以填充空间。这是针对HTML电子邮件的,因此无法使用Div。

Codepen: http://codepen.io/leongaban/pen/HkDyx

enter image description here

<td style="100%" height="1">
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr><td width="100%" height="1" bgcolor="#f67b1e"></td></tr>
  </table>
  <!-- <hr style="width: 100%; border-right: 0; border-left: 0; border: 1px solid #f67b1e;"> -->
</td>

2 个答案:

答案 0 :(得分:1)

这里你只需要声明这些行的宽度

<table width="600" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3" height="20" bgcolor="gray"></td>
  </tr>

  <tr id="wants_an_intro" style="font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color:#006497; text-align:center; font-size:24px; color: #f67b1e; width: 100%;">

    <td style="width:30%" height="1"> <!-- width:30% -->
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr><td width="100%" height="1" bgcolor="#f67b1e"></td></tr>
      </table>
      <!-- <hr style="width: 100%; border-right: 0; border-left: 0; border: 1px solid #f67b1e;"> -->
    </td>

    <td style="font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size:1em; color:#f67b1e;">wants an intro to</td>

    <td style="width:30%" height="1"> <!-- width:30% -->
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr><td width="100%" height="1" bgcolor="#f67b1e"></td></tr>
      </table>
      <!-- <hr style="width: 100%; border-right: 0; border-left: 0; border: 1px solid #f67b1e;"> -->
    </td>

  </tr>

  <tr>
    <td colspan="3" height="20" bgcolor="gray"></td>
  </tr>
</table>

或--------

<table width="600" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3" height="20" bgcolor="gray"></td>
  </tr>

  <tr id="wants_an_intro" style="font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color:#006497; text-align:center; font-size:24px; color: #f67b1e; width: 100%;">

    <td  width="30%" style="" height="1">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr><td width="100%" height="1" bgcolor="#f67b1e"></td></tr>
      </table>
      <!-- <hr style="width: 100%; border-right: 0; border-left: 0; border: 1px solid #f67b1e;"> -->
    </td>

    <td style="font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size:1em; color:#f67b1e;">wants an intro to</td>

    <td width="30%" style="" height="1">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr><td width="100%" height="1" bgcolor="#f67b1e"></td></tr>
      </table>
      <!-- <hr style="width: 100%; border-right: 0; border-left: 0; border: 1px solid #f67b1e;"> -->
    </td>

  </tr>

  <tr>
    <td colspan="3" height="20" bgcolor="gray"></td>
  </tr>

</table>

答案 1 :(得分:1)

只需将width设置为两行的td或一行,文字取决于您想要的内容

观看演示 http://codepen.io/anon/pen/racJt