TCPDF - 内部 css 不工作
TCPDF - Internal css not working
当我使用以下样式时,一切正常。
<style>
table{
border: 0.5px solid black;
border-collapse: separate;
border-spacing: 0;
}
</style>
但是当我使用 class 时,代码无法正常工作。
<style>
.tableWithOuterBorder{
border: 0.5px solid black;
border-collapse: separate;
border-spacing: 0;
}
</style>
以下是我的详细代码。
$htmlData = "<html><head>";
$htmlData .= "<style>
.tableWithOuterBorder{
border: 0.5px solid black;
border-collapse: separate;
border-spacing: 0;
}
</style>";
$htmlData .= "</head><body>";
$htmlData .= "<table class='tableWithOuterBorder'><tr><td>Hello</td><td>Sir</td></tr></table>";
$htmlData .= "</body></html>";
$pdf->writeHTML($htmlData, true, false, false, false, '');
我的代码有什么问题?
你好更改下面的行,
$htmlData .= "<table class='tableWithOuterBorder'><tr><td>Hello</td><td>Sir</td></tr></table>";
到
$htmlData .= '<table class="tableWithOuterBorder"><tr><td>Hello</td><td>Sir</td></tr></table>';
只需在双引号 (") 中输入 class 名称,一切正常。
我的最终代码现在是:
$htmlData = '<html><head>';
$htmlData .= '<style>
.tableWithOuterBorder{
border: 0.5px solid black;
border-collapse: separate;
border-spacing: 0;
}
</style>';
$htmlData .= '</head><body>';
$htmlData .= '<table class="tableWithOuterBorder"><tr><td>Hello</td><td>Sir</td></tr></table>';
$htmlData .= '</body></html>';
$pdf->writeHTML($htmlData, true, false, false, false, '');
谢谢
当我使用以下样式时,一切正常。
<style>
table{
border: 0.5px solid black;
border-collapse: separate;
border-spacing: 0;
}
</style>
但是当我使用 class 时,代码无法正常工作。
<style>
.tableWithOuterBorder{
border: 0.5px solid black;
border-collapse: separate;
border-spacing: 0;
}
</style>
以下是我的详细代码。
$htmlData = "<html><head>";
$htmlData .= "<style>
.tableWithOuterBorder{
border: 0.5px solid black;
border-collapse: separate;
border-spacing: 0;
}
</style>";
$htmlData .= "</head><body>";
$htmlData .= "<table class='tableWithOuterBorder'><tr><td>Hello</td><td>Sir</td></tr></table>";
$htmlData .= "</body></html>";
$pdf->writeHTML($htmlData, true, false, false, false, '');
我的代码有什么问题?
你好更改下面的行,
$htmlData .= "<table class='tableWithOuterBorder'><tr><td>Hello</td><td>Sir</td></tr></table>";
到
$htmlData .= '<table class="tableWithOuterBorder"><tr><td>Hello</td><td>Sir</td></tr></table>';
只需在双引号 (") 中输入 class 名称,一切正常。
我的最终代码现在是:
$htmlData = '<html><head>';
$htmlData .= '<style>
.tableWithOuterBorder{
border: 0.5px solid black;
border-collapse: separate;
border-spacing: 0;
}
</style>';
$htmlData .= '</head><body>';
$htmlData .= '<table class="tableWithOuterBorder"><tr><td>Hello</td><td>Sir</td></tr></table>';
$htmlData .= '</body></html>';
$pdf->writeHTML($htmlData, true, false, false, false, '');
谢谢