相关的HTML如下所示:
<li class="lineEntry t1" title="Right-Click for Options" style="">
<span id="job_111095">
<i class="ic-p-appr"></i> 111095
</span> Foo/Bar, Some Text </span>
</li>..。相关的CSS如下所示( file =图标的foo.css ) ...
/* this is an icomoon icon, that should be green */
.ic-p-appr:before {
content: "\e905";
color: #0f8040 !important;
}..。和( file = bar.css ) ...
.t1{color:#B92426;}
/* .line-entry never defines a color */我已经添加了!important并在bar.css之后加载了foo.css,以使图标变绿(#0f8040),但是.t1类中嵌套的图标总是继承父类的字体颜色,只有当mpfd将HTML转换为pdf文档时。( HTML中的嵌套图标按预期工作)
当我查看支持的CSS的mPDF文档时,我看不到任何东西,所以这说明了为什么会发生这种情况。我的mPDF是7,配置如下:
$mpdf = new \Mpdf\Mpdf([
'fontDir' => array_merge($fontDirs, [
'../vendor/resources/fonts',
]),
'fontdata' => $fontData + [
'icomoon' => [
'R' => 'icomoon.ttf',
],
],
'format' => 'A4-L',
'orientation' => 'L',
'debug' => true,
]);请参阅:感谢enter image description here对此问题的帮助。
发布于 2020-01-21 00:28:52
修复:我发现由于mPDF ver7不支持CSS伪类:在此之前,有必要使用类名独立声明字体颜色。因此,对于我的HTML输出,.ic-p-appr:before { color:#0f8040 !important;}起作用了,但是我必须再次声明它,去掉':before‘,以便在PDF文档中注册该样式。
摘要: mPDF7忽略在伪类下声明的CSS样式属性。
https://stackoverflow.com/questions/59794053
复制相似问题