我在从 dompdf 创建 pdf 时遇到小问题。在html页面标题位置:固定内容重叠在页面标题上。页面内容是动态加载的。如何解决内容重叠问题。html版本像这个链接html
定位内容当前根据主内容容器或
body
元素放置。为了确保没有重叠,请在页面上添加边距,然后将内容反向定位以将其移到正文之外 (#header { position: fixed; top: -50px; left: 0px; right: 0px; height: 50px; }
)。
例如:
<html>
<head>
<style>
@page { margin: 50px; }
body { background-color: #c0ccff; padding: 1em; }
#header { position: fixed; top: -50px; left: 0px; right: 0px; height: 50px; background-color: orange; padding: .5em; text-align: center; }
</style>
</head>
<body>
<div id="header">HEAD</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tempor gravida enim, id sollicitudin eros ullamcorper a. Cras vitae convallis dolor. Maecenas eget fermentum magna. Donec gravida neque vel sapien congue consequat. Nulla facilisi. Sed volutpat dui et nibh posuere, eu malesuada arcu congue. Cras vehicula elit eros, non tristique leo congue quis. Morbi aliquam scelerisque augue, eu sodales dolor. Integer a commodo nibh. </p>
<div style="page-break-before: always;"></div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tempor gravida enim, id sollicitudin eros ullamcorper a. Cras vitae convallis dolor. Maecenas eget fermentum magna. Donec gravida neque vel sapien congue consequat. Nulla facilisi. Sed volutpat dui et nibh posuere, eu malesuada arcu congue. Cras vehicula elit eros, non tristique leo congue quis. Morbi aliquam scelerisque augue, eu sodales dolor. Integer a commodo nibh. </p>
</body>
</html>