如何使用html和css对齐MSO Word文档的页脚文本?

How to align footer text left and right of MSO Word document using html & css?

提问人:Lucas Argueza 提问时间:1/8/2022 最后编辑:macropodLucas Argueza 更新时间:12/1/2022 访问量:574

问:

在这个问题上卡住了很长时间。任何帮助都是值得赞赏的。提前致谢。

因此,我应该生成格式取自 xhtml 模板的报告(Word 文档)。目前,我正在尝试设置页脚的格式,使其在左侧具有报表名称,在右侧和同一行中具有页码。我可以将文本放在相反的两侧,但是我无法将两段文本放在同一行上。也许这是 Word 呈现 html 的方式?我似乎想不通。

这是给我的默认代码:

<div style='mso-element:footer' id='f1'>
<div style='mso-element:para-border-div;border:none;border-top:solid #005686 1.0pt;
mso-border-top-alt:solid #005686 .5pt;padding:1.0pt 0in 0in 0in; width:100%'>
<p class=MsoNormal align=right style='text-align:left;border:none;mso-border-top-alt:
solid #005686 .5pt;padding:0in;mso-padding-alt:1.0pt 0in 0in 0in'>
<span style='color:#005686'>
<!--REPORT-TITLE-->
</span>
<span style='float:right;color:#005686'>Page</span> 
<!--[if supportFields]><span style='color:#005686'><span
style='mso-element:field-begin'></span>PAGE \* MERGEFORMAT<span
style='mso-element:field-separator'></span></span><![endif]--> 
<span style='color:#005686;mso-no-proof:yes'>1</span>
<span style='color:#005686'> </span>
<!--[if supportFields]><span
style='color:#005686;mso-no-proof:yes'><span style='mso-element:field-end'></span></span><![endif]-->
<span style='font-size:10.0pt;color:#005686'>
<o:p></o:p>
</span>
</p>

</div>

<p class=MsoNormal>
<o:p>&nbsp;</o:p>
</p>

</div>
HTML CSS MS-Word XHTML MS-Office

评论


答:

0赞 Serdar Günaydın 2/1/2022 #1

浮点数不适用于 office,只需像这样放置表代码。

 <div style='mso-element:footer' id='f1'>  <table style="width: 100%;" class="noborder">
        <tr>
            <td style="width: 50%;text-align: left;">
                <div style='mso-element:para-border-div;border:none;border-top:solid #005686 1.0pt;
            mso-border-top-alt:solid #005686 .5pt;padding:1.0pt 0in 0in 0in; width:100%'>
                    <p class=MsoNormal align=right style='text-align:left;border:none;mso-border-top-alt:
            solid #005686 .5pt;padding:0in;mso-padding-alt:1.0pt 0in 0in 0in'>
                        <span style='color:#005686'>
                            <!--REPORT-TITLE-->
                        </span>
            </td>
            <td style="width: 50%; text-align: right;">
                <span style='color:#005686'>Page</span>
                <!--[if supportFields]><span style='color:#005686'><span
                style='mso-element:field-begin'></span>PAGE \* MERGEFORMAT<span
                style='mso-element:field-separator'></span></span><![endif]-->
                <span style='color:#005686;mso-no-proof:yes'>1</span>
                <span style='color:#005686'> </span>
                <!--[if supportFields]><span
                style='color:#005686;mso-no-proof:yes'><span style='mso-element:field-end'></span></span><![endif]-->
                <span style='font-size:10.0pt;color:#005686'>
                    <o:p></o:p>
                </span>
                </p>
            </td>
        </tr>
    </table></div>



<style>
 //noborder css       
  .noborder,
    .noborder tr,
    .noborder th,
    .noborder td {
        font: 11pt "Calibri";
        border: none;
    }</style>