mpdf - 使用 CSS 修复 mpdf 中 sup 标签上方的额外间距
问题描述
是否可以在 mpdf 中调整行高、填充或边距?我尝试将下面的代码应用于 mpdf 的 css 文件,但没有任何属性生效,甚至没有背景颜色。
sup{
line-height: .6em;
top: -10px;
font-size: 0.63em;
vertical-align: super;
padding-bottom: 20px;
margin-bottom: 10px;
border-bottom: solid 1px #000000;
display: inline-block;
background: yellow;
}
<p>Phasellus nec lectus in risus consequat hendrerit non eu elit. Fusce imperdiet, ante sed maximus 6<sup>th</sup>, nulla augue ultrices nibh, vel ornare ligula dolor sed est.<p>
解决方案
根据文档,有一些方法可以实现这一点。选择其中之一,让魔法发生。
CSS 样式表 - 包含在 HTML 文档的标题中或作为 @import()
css-stylesheets
- html标签例如
p { font-size:12pt; color:#880000; }
- 类例如
.stylename { font-size:9pt; }
- 身份证例如
#style { font-size:9pt; }
- 内联 CSS 样式,例如
<p style="font-family:monospace;">
以及我更喜欢使用的方式。
使用样式表文件。
WriteHTML() 方法采用第二个参数,即$mode。有关此参数和其他参数的详细信息,请参阅 WriteHTML()。
使用样式表的示例
<?php
$stylesheet = file_get_contents('style.css');
$mpdf->WriteHTML($stylesheet,\Mpdf\HTMLParserMode::HEADER_CSS);
$mpdf->WriteHTML($html,\Mpdf\HTMLParserMode::HTML_BODY);
否则请阅读本文。它也可以帮助你。 仅在 CSS 中的上标
推荐阅读
- azure-functions - 服务总线触发 Azure 功能 .net core 3.1
- ssl-certificate - 在防火墙后运行的 Ant Media Server 的代理设置
- ios - 如何在 Slider 中禁用最小值 0?
- c - 为什么只在声明后才为变量赋值
- office-js - Microsoft Teams 应用在发布时通过认证步骤需要多长时间?
- javascript - 如何自动关注列表的第一个元素
- c++ - std::decay 在 std::is_convertible 中是多余的吗?
- python - 在第二个 MacBook Pro 桌面上执行 PyAutoGUI 代码
- python - 如果我最初输入正确的输入,函数就可以工作,但是如果我尝试输入错误的输入然后输入正确的输入,它会给我一个属性错误
- python - 读取响应 python