Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

公司有个需求打印一些公司的合同的时候要给每一页添加一个logo之前采用的办法是给页面添加多个img然后设置绝对定位top值现在发现打印出来有时候后面几页没有图片 怎么才能获取到这个网页打印的总页数呢 之前用的办法有问题


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.9k views
Welcome To Ask or Share your Answers For Others

1 Answer

@media print 用这个来设置CSS打印属性

——————

test.html

<!DOCTYPE html>
<head>
  <style>
    .background {
      position: fixed;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      z-index: -1;
      background: url(https://cdn.colorhub.me/imgsrv/9957a1bfc45d18ef09645dff1352cf7bab011fee);
      background-position: center center;
      background-repeat: no-repeat;
      display: none;
    }

    .content {
      padding: 600px 0;
      text-align: center;
      font-size: 50px;
      color: red;
    }

    @media print {
      .background {
        display: block;
      }
    }
  </style>
</head>

<body>
  <div class="background"></div>
  <div class="main">
    <div class="content">
      第1部分
    </div>
    <div class="content">
      第2部分
    </div>
    <div class="content">
      第3部分
    </div>
    <div class="content">
      第4部分
    </div>
  </div>
</body>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...