如何中心的HTML表格? [英] How to center html table?
问题描述
你能帮我吗,我如何使用writeHTML函数在TCPDF中创建和居中表?
Trying to create proper PDF document, using PHP and TCPDF.
试用:
Can you help me, how can I use writeHTML function to create and center table, in TCPDF?
Tryed with:
< br />
< / div>
$html = '
<div style="margin-left: auto; margin-right: auto; width: 50%">
<table border="1" width="200" align="center"><tr><td><b>Invoice number: '.$this->xInvoiceNumber.'</b></td></tr></table>
<br />
<table border="1" width="200" align="center"><tr><td>'.$this->xClient.'</td></tr></table>
<br />
</div>
...但没有运气。
... but no luck.
推荐答案
你必须制作一个3列的表格,为每一个表格设置宽度,并在中间创建一个表格。
You have to make a table with 3 columns, set the width for every one of them and in the middle one you have to create your table.
<table>
<tr>
<td style="width:25%"></td>
<td style="width:50%"><table><tr><td>Your content</td></tr></table></td>
<td style="width:25%"></td>
</tr>
</table>
我不为这种方法感到自豪,但它正在工作:)
I'm not proud of this method but it's working :)
这篇关于如何中心的HTML表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!