代码之家  ›  专栏  ›  技术社区  ›  Gaurav_soni

打印时分区重叠

  •  0
  • Gaurav_soni  · 技术社区  · 6 年前

    当我打印以下代码时,绿色页脚与黄色容器重叠。我需要黄色在打印时遇到页脚时断开并转到下一页。

    HTML如下

    <body>
        <div class="container">
                This is the container
        </div>
        <div class="footer">
            This is the footer
        </div>
    </body>
    

    CSS如下

    body{
        height: 100vh;
        margin: 0;
        -webkit-print-color-adjust:exact;
    }
    
    .container{
        background-color:yellow;
        width: 100%;
        height: 1500px;
    
    }
    
    .footer{
        position: fixed;
        bottom: 0;
        width: 80%;
        height: 100px;
        background-color: #21f50056 
    }
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Gaurav_soni    6 年前

    最后使用了javascript,在添加任何元素之前,我检查了容器的高度。如果高度超过了页面高度,请插入分页符。