0

对于一些装饰,我需要在文档的开头插入一个上边距,它代表页面整个高度的 34%(包括边距)。
我的页面 <body> 是这样开始的:

    <body bgcolor="#dedede" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="-webkit-text-size-adjust:none;">
        <tbody>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#dedede">
                <tr>
                    <td>
                        <table class="premier-tableau" width="600" bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" align="center">
                        <thead>
                                <tr height="500" /> <!-- I need to use this line as a margin -->
                        </thead>
                        <tbody>
                            <tr>
                                <td width="35" />
                                <td width="530">
                                    <font color="#5e5e5e" face="Arial, Helvetica, sans-serif" size="2" style="font-size: 12px;">

这是在电子邮件中使用的。

当然也可以手动计算像素数,并将静态结果添加到<tr>标签中。但是,它是半自动化过程的一部分,我想避免这种情况。
另请注意,目标 SMTP 服务器可能有严格的策略并拒绝附件。所以,我看不到如何使用外部库(例如 JQuery)。由于可以使用现代 ecmascript,我想避免使用它们...

接受任何可嵌入的解决方案(css;javascript;svg ...)。

4

3 回答 3

2

document.body.parentNode.offsetHeight但是 - javascript 不会在电子邮件中运行 :) 因此我认为您需要手动执行此操作。

于 2013-11-14T02:18:06.443 回答
0

由于您的身体没有边距,因此应该使用简单的高度。

document.getElementsByTagName("body")[0].height
于 2013-11-14T02:22:18.100 回答
-1

有为此设计的视口单元。实际上很少有浏览器支持它,但height="34vh"在几年后使用将是正确的方法。

客户需要几年时间才能遵守该标准。现在进行的实际方法是每次编辑文档时手动计算大小(以 px 为单位)。

于 2013-11-24T00:24:34.160 回答