【发布时间】:2018-06-05 04:33:29
【问题描述】:
我正在尝试格式化表格以使行由行分隔。甚至尝试使用内联样式但没有任何效果。我在这里错过了什么吗?
这是我用来为电子邮件生成 HTML 的 perl 代码:
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();
【问题讨论】:
-
如果你为
table元素定义border-collapse: collapse; border: 1px solid black;,你会得到你想要的,你可以从td、th和tr删除所有的边框样式。 -
@FBergo 不,没用... .changed 删除了所有其他css并将表格更改为“ $section_html.=qq(
);"Hello1 Hello2 Hello3 Hello4 tr> -
生成的 HTML 在浏览器上正确渲染,只有通过 Outlook 渲染 HTML 时出现问题
-
哦,那就看看这个:stackoverflow.com/questions/43462203/…(outlook 的 HTML 渲染有它的怪癖)
标签: html perl outlook html-email