久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

打印:如何將每頁的頁腳粘貼到底部?

Print: How to stick footer on every page to the bottom?(打印:如何將每頁的頁腳粘貼到底部?)
本文介紹了打印:如何將每頁的頁腳粘貼到底部?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試將生成的 HTML 文檔打印為 PDF.文檔本身可以包含多個頁面.每個頁面都是這樣構建的:

I'm trying to print a generated HTML document to PDF. The document itself can hold multiple pages. Every page is built up like this:

<!-- Header -->

<!-- Content -->

<!-- Footer -->

這三個在每一頁上看起來都很好.唯一的問題是頁腳不會粘在底部......頁腳將始終趕上頁面的最后一個元素.只要頁面填充了足夠的內容,頁腳就會像您期望的那樣位于底部.

All three look fine on every page. The only problem is that the footer won't stick at the bottom... The footer will always catch up with the last element of the page. As long as the page is filled with enough content the footer will be at the bottom as you would expect it to be.

這是我的 CSS:

.docFooter{
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    width: 100%;
    position: absolute;
    bottom: 0;
    padding-right: 2cm;
    padding-bottom: 1cm;
}

我也嘗試過像這樣生成一個單獨的 CSS:

I've also tried to generate a separate CSS like this:

@media print{
    .docFooter{
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-pack: justify;
        -ms-flex-pack: justify;
        justify-content: space-between;
        width: 100%;
        position: absolute;
        bottom: 0;
        padding-right: 2cm;
        padding-bottom: 1cm;
    }
}

當然,我正在使用這樣的 CSS:

And of course I'm using the CSS like this:

<link rel="stylesheet" href="./main.min.css" media="all">

旁注:

  • 我只需要 Chrome 支持,因為我正在使用 electron 框架
  • 進行開發
  • 我正在使用這個:https://github.com/delight-im/HTML-Sheets-of-Paper CSS 文件使頁面可見,就像它們將要打印給用戶一樣.
  • Logic 使用 Node.js 7.5 構建
  • I just need Chrome support, since I'm developing with the electron framework
  • I'm using this: https://github.com/delight-im/HTML-Sheets-of-Paper CSS files to make pages visible like they are going to be printed to the user.
  • Logic is built with Node.js 7.5

我做了一些研究并嘗試了這些問題的答案,但沒有成功:

I did some research and tried out the answers from these questions with no success:

  • 將自定義頁腳粘貼到每頁底部同時打印
  • 在打印時特定頁面的底部
  • 如何使用 HTML 在文檔的每個打印頁面上打印頁眉和頁腳?

那么有沒有可能用純 CSS 來實現呢?如果沒有,我還會構建一些邏輯來填充頁腳上方的所有空白空間,直到頁面達到其最大尺寸.

推薦答案

好的,由于某些奇怪的原因,解決方案非常簡單.但是我已經改變了我的 CSS:

Ok, the solution was super easy for some strange reason. However I've changed my CSS from this:

.docFooter{
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    width: 100%;
    position: absolute;
    bottom: 0;
    padding-right: 2cm;
    padding-bottom: 1cm;
}

到這里:

display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    width: 100%;
    position: absolute;
    top: 27.7cm !important;
    padding-right: 2cm !important;

因為我知道 A4 頁面不會超過 29.7cm,所以很容易將元素設置到底部,同時使用 top: 27.7cm

Since I know that a A4 page won't exceed 29.7cm it was easy to set the element to the bottom while making it absolute positioned coming from top with top: 27.7cm

這篇關于打印:如何將每頁的頁腳粘貼到底部?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 久久91av| 欧美精品在线免费 | 久久久精 | 国产精品美女久久久久久免费 | 成人午夜视频在线观看 | 在线观看免费av网 | 久久9999久久 | 欧美网址在线观看 | 久久久久久久久久久丰满 | 国产免费一区二区三区网站免费 | 色www精品视频在线观看 | 久亚州在线播放 | 色香蕉在线| 欧美激情国产精品 | 国产精品a久久久久 | 免费在线观看av片 | 久久久国产精品入口麻豆 | 日韩三级视频 | 国产精品观看 | 亚洲91精品 | 中文字幕一区在线 | 国产精品成人久久久久 | 久久久久国产精品午夜一区 | 精品久久久久久18免费网站 | 黄色一级视频免费 | 成人在线精品视频 | 91社区在线观看 | 国产精品网址 | 91电影在线 | 成人av高清| 精产国产伦理一二三区 | 99久久精品国产一区二区三区 | 亚洲国产小视频 | 东京久久 | 欧美精品久久久 | 四虎影| 午夜天堂精品久久久久 | 99成人在线视频 | 欧美一区二区三区在线观看 | 欧美精品福利 | 成人亚洲精品 |