0
点赞
收藏
分享

微信扫一扫

itext中通过freemark生成的pdf时,居中样式text-align: center没有效果

司马吹风 2024-02-15 阅读 13

itext不支持css3的语法,结果css2的部分语法也可能不支持,比如text-align: center,一直没有效果,后来想到用table的方式

原始的代码: css 的 container中添加   text-align: center;

<div class="container">

    <span class="title">这边是要居中的内容</span>

    <span class="spanimg"><img src="https://www.baidu.com/img/bdlogo.png  " width="180px" height="80px"/></span>

</div>

修改成table后可以用

    <table  style="width: 100%;text-align: center;">

        <tr>

            <th width="30%"></th>

            <th>这边是要居中的内容</th>

            <th><img src="https://www.baidu.com/img/bdlogo.png  " width="180px" height="80px"/></th>

        </tr>

    </table>

举报

相关推荐

0 条评论