首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >HTML电子邮件<tr>标记边框格式问题

HTML电子邮件<tr>标记边框格式问题
EN

Stack Overflow用户
提问于 2018-06-05 12:33:29
回答 1查看 207关注 0票数 0

我正在尝试格式化表格,使行由lines.Even分隔,尝试使用内联样式,但都不起作用。我是不是漏掉了什么?

预期输出:

我得到的输出:

下面是我用来为电子邮件生成HTML的perl代码:

代码语言:javascript
复制
my $section_html = '';
$section_html.=qq(<table><tr style="border : 1px solid black;"><td>Hello1</td><td>Hello2</td></tr><tr style="border : 1px solid black;"><td>Hello3</td><td>Hello4</td></tr></table>);

my $email_html = <<EOF;
<html><head><style type="text/css">
body, td, th, strong { font-family: Verdana; font-size: 11px; }


table {
    border:none;
    border-collapse: collapse;
    text-align:center;
}

table td {
    border-left: 1px solid #000;
    border-right: 1px solid #000;
}

table th {
    border-left: 1px solid #000;
    border-right: 1px solid #000;
}

table td:first-child {
    border-left: none;
    text-align:left;
}

table  td:last-child {
    border-right: none;
}

table tr{
border-top : 1px solid #000;
}

table tr{
border-top : 1px solid black;
}


</style></head>
<body bgcolor="#ffffff">
<span style="font-size: 20px">Report Header</span>$section_html</body></html>
EOF

# Write to file
open(FILE, ">/var/weekly_report/"."report"."_"."testing".".html") or die "Unable to open file for writing: $!\n";
print FILE $email_html;
close(FILE);


# Email weekly report
my $msg = MIME::Lite->new(
    To         => 'XXXX@somedomain.com',
    Subject => 'Report subject',
    Type    => 'text/html',
    Data    => $email_html);


    $msg->send();
EN

回答 1

Stack Overflow用户

发布于 2018-06-06 09:10:12

这是老生常谈。也可以尝试这种方法。与Ted的答案不同的是,您拥有相同颜色的整个表格,在他的答案中,您可以为不同的td'sth's选择边框颜色。

代码语言:javascript
复制
<table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#000000">
  <tbody>
    <tr>
      <td width="50%" bgcolor="#ffffff">Hello1</td>
      <td width="50%" bgcolor="#ffffff">Hello1</td>
    </tr>
    <tr>
      <td bgcolor="#ffffff">Hello1</td>
      <td bgcolor="#ffffff">Hello1</td>
    </tr>
  </tbody>
</table>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50692098

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档