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, '');

我的代码有什么问题?

Hello Change

$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>';

只要在类名中加上双引号("),一切都可以正常工作。

我的最终代码是现在:

$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, '');

谢谢