【问题标题】:Table row bottom border is not visble when converting html to MS word将html转换为MS word时表格行底部边框不可见
【发布时间】:2022-01-02 04:12:05
【问题描述】:

我正在尝试使用以下方法将一些 HTML 内容转换为 MS word,但是我尝试设置为表格行的某些样式(例如边框底部)在转换后的 word 文档中根本不可见.有人可以帮我吗?

<html xmlns:v="urn:schemas-microsoft-com:vml"
    xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:w="urn:schemas-microsoft-com:office:word"
    xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
    xmlns="http://www.w3.org/TR/REC-html40">
    <body>
        <table>
            <tr style="border-bottom:2pt solid #AFAFAF">
               <td>One</td>
               <td>1</td>
            </tr>
            <tr style="border-bottom:2pt solid #AFAFAF">
               <td>One</td>
               <td>1</td>
             </tr>
        </table>
    </body>
</html>

我什至尝试设置 style="mso-border-bottom-alt: solid #AFAFAF 2pt;" 也不起作用。我的要求非常具体,我应该为每一行设置底部边框。

【问题讨论】:

  • 尝试将边框放置到td
  • 将border-bottom 设置为td 是有效的,但是两个 的边框之间有一个我不想要的微小间隙。我想要每行下方的直线底部边框。您还有其他建议吗?
  • CELLSPACING="0" 设置为 以及将边框底部应用于

标签: html css html-table ms-word


【解决方案1】:

正如Azu 所述,将border-bottom 设置为&lt;td&gt; 而不是&lt;tr&gt; 标记与cellspacing="0" 上的&lt;table&gt; 一起起到了作用。

<html xmlns:v="urn:schemas-microsoft-com:vml"
    xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:w="urn:schemas-microsoft-com:office:word"
    xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
    xmlns="http://www.w3.org/TR/REC-html40">
    <body>
        <table width="100%" cellspacing="0">
            <tr>
               <td style="border-bottom:2pt solid #AFAFAF">One</td>
               <td style="border-bottom:2pt solid #AFAFAF">1</td>
            </tr>
            <tr>
               <td style="border-bottom:2pt solid #AFAFAF">One</td>
               <td  style="border-bottom:2pt solid #AFAFAF">1</td>
             </tr>
        </table>
    </body>
</html>

【讨论】:

    猜你喜欢
    相关资源
    最近更新 更多
    热门标签