Php mPDF:文本与表中的p、h1-h6对齐无效
此代码不适用于带有mPDF php类的表 但不起作用,在td之间,它是来自编辑器tinymce的html 这是来自脚本的完整代码 当输出找到内容时,td文本左对齐而不是右对齐或居中对齐Php mPDF:文本与表中的p、h1-h6对齐无效,php,html,css,tinymce,mpdf,Php,Html,Css,Tinymce,Mpdf,此代码不适用于带有mPDF php类的表 但不起作用,在td之间,它是来自编辑器tinymce的html 这是来自脚本的完整代码 当输出找到内容时,td文本左对齐而不是右对齐或居中对齐 <?php $html = ' <h1>mPDF</h1> <table style="border-collapse: collapse; font-size: 12px; font-weight: 700; margin-top: 5px
<?php
$html = '
<h1>mPDF</h1>
<table style="border-collapse: collapse;
font-size: 12px;
font-weight: 700;
margin-top: 5px;
border-top: 1px solid #777;
width: 100%;">
<tbody>
<tr>
<td class="contentDetails">
<h3 style="text-align: right;"><strong>text align right</strong></h3>
<h3 style="text-align: center;"><strong>text align center</strong></h3>
<h3 style="text-align: left;"><strong>text align left</strong></h3>
</td>
</tr>
</tbody>
</table>';
include("mpdf.php");
$mpdf=new mPDF('c');
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
?>
问题是容器的宽度与内容相符。将表格
宽度设置为100%
表格{
宽度:100%;
}
文本右对齐
文本居中对齐
文本左对齐
尝试下面的代码。我想这会对你有帮助
<table width="100%">
<tr>
<td class="contentDetails">
<th align="left"> <h3><strong>text align right</strong></h3></th>
<th align="center"> <h3><strong>text align center</strong></h3></th>
<th align="right"> <h3><strong>text align left</strong></h3></th>
</td>
</tr>
</table>
文本右对齐
文本居中对齐
文本左对齐
在这里使用额外的标签。我已经准备了很多小时的内容来打印(mPdf v.6)。现在我可以给大家提个建议了。不要使用表格来对齐内容或只是保持内容。几乎所有元素的css属性都可以正常工作。但是-但是不能嵌套在表中 你的问题是什么?文本对齐:在h3中不工作?文本与p对齐,h1-h6在表格中不起作用请发布您的问题的演示。更新更多细节不起作用,但我认为必须使用tcpdf。与CSS对齐比mpdf更好与mpdf或tcpdf无关:)最好的答案是在td ContentDetails的新表格中使用它。查看此最终代码33333
你说得对“但是-但是不能嵌套在表中。”
<?php
$html = '
<h1>mPDF</h1>
<table style="border-collapse: collapse;
font-size: 12px;
font-weight: 700;
margin-top: 5px;
border-top: 1px solid #777;
width: 100%;">
<tbody>
<tr>
<td class="contentDetails">
<h3 style="text-align: right;"><strong>text align right</strong></h3>
<h3 style="text-align: center;"><strong>text align center</strong></h3>
<h3 style="text-align: left;"><strong>text align left</strong></h3>
</td>
</tr>
</tbody>
</table>';
include("mpdf.php");
$mpdf=new mPDF('c');
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
?>
<table width="100%">
<tr>
<td class="contentDetails">
<th align="left"> <h3><strong>text align right</strong></h3></th>
<th align="center"> <h3><strong>text align center</strong></h3></th>
<th align="right"> <h3><strong>text align left</strong></h3></th>
</td>
</tr>
</table>