首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS打印重复内容

CSS打印重复内容
EN

Stack Overflow用户
提问于 2020-03-19 00:41:00
回答 1查看 435关注 0票数 0

我一直在尝试为一个组件创建自定义样式,它需要打印,问题是我想打印的东西都是重复的。

我试着用codepen重新创建,但我不能。

这是我添加到css打印中的内容:

代码语言:javascript
复制
@media print and (color) {
  @page {
    margin: 5mm;
    size: A4 landscape;
  }

  * {
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #212121 !important;
    visibility: hidden;
  }
  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
  }
  body,
  .section-to-print {
    height: auto !important;
  }
  .section-to-print,
  .section-to-print * {
    visibility: visible !important;
  }
  .section-to-print {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    display: block !important;
  }
  .section-to-print:nth-child(2) {
    display: none !important;
  }
  .vis-timeline {
    display: none;
  }
  core-dialog,
  .dialog-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
  }
}
EN

回答 1

Stack Overflow用户

发布于 2020-03-19 21:39:23

原来问题是父元素有"position:fixed",这就是我的问题中重复的原因。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60743879

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档