如何中心的HTML表格? [英] How to center html table?

查看:82
本文介绍了如何中心的HTML表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能帮我吗,我如何使用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:
< table border =1width =200align =center>< tr>< td>< b>发票号码:'。$ this-> xInvoiceNumber。'< ; / b>< / TD>< / TR>< /表>
< br />
< 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆