我正在尝试使用Dompdf生成pdf。我有以下脚本来设计我生成的pdf。
<html>
<head>
<style>
@page { margin: 180px 50px; }
#header { position: fixed; left: 0px; top: -180px; right: 0px; height: 120px; background-color: orange; text-align: center; }
#footer { position: fixed; left: 0px; bottom: -180px; right: 0px; height: 150px; background-color: lightblue; }
#footer .page:after { content: counter(page, upper-roman); }
</style>
<body>
<div id=\"header\">
<h1>Charlie Sheen</h1>
</div>
Hi, This is Charlie Sheen <br>
<p> Winning </p>
<p> Winning </p>
<p> Winning </p>
<p> Winning </p>
<p> Winning </p>
<p> Winning </p>
<p> Winning </p>
<div id=\"footer\">
<p class=\"page\">Page </p>
</div>
<div id=\"content\">
<p>the first page</p>
<p style=\"page-break-before: always;\">the second page</p>
</div>
</body>
</html>
当我生成PDF时,它看起来像上面的图像。现在我的问题是我希望我的内容从现在开始的一点点开始。如果您注意到上面的图像,则会出现一个句子“嗨,这是查理·辛”......我希望这可以从一个小鞋帮开始。我试图在样式中添加以下代码,但它不起作用:
#content { position: fixed; margin-top: 0px;}
请你帮我把内容从一个小高层开始?
提前致谢:)
答案 0 :(得分:0)
更改#content
上的边距不会产生任何影响,因为#content
位于页面下方。
我会考虑用p
标签包装第一句话,就像这样
<p>Hi, This is Charlie Sheen</p>