4

我试图让 MPDF 正确打印带有溢出的 div:隐藏。我已经上下阅读了他们的文档并尝试了各种方法。没运气。每个 mpdf,具有溢出:隐藏的块元素必须具有位置:绝对或位置:固定集。当您只打印一个 div 时,这很好。当我尝试嵌套 div 并需要内部的 div 来剪辑文本时,问题就出现了。这就是我的意思:

这打印得很好

$html = <<< EOM
<div style='width:300px;height:100px;position:absolute;overflow:hidden;border:1px solid black;'>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.  
</div>
$html = <<< EOM

这不

$html = <<< EOM
<div style='border:1px solid red;position:relative;'>
<div style='width:300px;height:100px;position:absolute;overflow:hidden;border:1px solid black;'>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.  
</div>
</div>
$html = <<< EOM

php脚本很简单

include("mpdf.php");
$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$mpdf->Output();

如您所见,唯一的区别是一个 div 在另一个 div 中。有没有人想出如何做到这一点?

4

1 回答 1

1

在 mpdf 中,您不能overflow: hidden;在嵌套 div 上使用。overflow: hidden;只能用于顶级元素。

于 2012-05-24T16:57:19.590 回答