gpt4 book ai didi

javascript - 如何在打印时添加出现在每一页上的图像横幅?

转载 作者:行者123 更新时间:2023-11-28 02:43:38 25 4
gpt4 key购买 nike

我需要打印一个 html 文档。本文档包含多页表格。现在,我需要一种在每个页面的页首添加横幅图像的方法。我试过使用“position:fixed”,但这个过程与我的表格行重叠。如果有人帮助我找到解决方案,我将不胜感激。

提前致谢。

@media print{
body div img{
position: fixed;
}
}

最佳答案

您可以尝试添加图像并使用 display:none 或其他样式隐藏它。然后在媒体打印中,用 for ex display:block 显示它。这样它就会在 table 前(或你想要的地方)

img {
display: none
}

@media print {
img {
display: block
}
}
<img src="http://via.placeholder.com/350x150">
<table>
<tr>
<td>table</td>
<td>table</td>
</tr>
<tr>
<td>table</td>
<td>table</td>
</tr>
<tr>
<td>table</td>
<td>table</td>
</tr>
</table>

关于javascript - 如何在打印时添加出现在每一页上的图像横幅?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47032723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com