html - HTML/css 在打印时重复背景图像两次
问题描述
我想让背景图像准确重复 2 次,在 chrome 上的打印格式的每一页中重复一次。总是有 2 页,而第二页不会一直向下。我还使用来自 php 的动态数据。我目前正在使用此代码,图像的第二次打印从第一页开始,而不是在第二页中显示:
<style type="text/css" media="print">
body
{
background-image:url(image.png);
background-repeat:repeat-y;
background-position: right top;
width:auto;
}
</style>
解决方案
这个问题在 CSS 中没有直接的解决方案。虽然你可以试试这个技巧:
<style type="text/css" media="print">
body{
background-image:url('red.png'),url('red.png');
background-repeat:no-repeat;
background-position: 0px top, 250px top;
}
</style>
您需要添加背景与您希望它重复的次数完全相同。您可以相应地更改其位置。
与属性的默认值一样也是width:auto;
多余的。auto
width
推荐阅读
- javascript - .map 在使用 useState 钩子触发 setState 后不是函数
- reactjs - 状态变化正在重置导航
- ios - 如何使用新的 App 结构实现 SceneDelegate 的场景(_:willConnectTo:options:) 中存在的代码
- gradle - 仅从 gradle spring boot 项目中的 maven 依赖项中检索到 pom.xml
- javascript - React 组件的阶段和 React 组件的生命周期有什么区别?
- python - Django objects.get() 函数不起作用,但 objects.filter().first() 起作用
- java - 元素链接没有重定向到它的目标页面?
- gradle - 如何跟踪泄漏的 Gradle API 依赖项
- python - 尝试使用 pygame 制作游戏的 Python 新手
- swift - 带有资源的 Swift 包管理器编译错误