简体   繁体   中英

How to change the position of window.print() pages number?

Does anyone know how to move the sheets of paper-number position from the right-bottom to the top-bottom?

Thanks.

页码示例

You can't change the position of the page number when using the window.print() method. The page number is automatically added by the browser when the user prints the page, and its position and formatting are determined by the user's print settings and the browser's default styles for the @page CSS rule.

If you want to have more control over the page number and its position, you can use a CSS-based approach to print your page.

 @media print { @page { margin: 0; size: auto; width: 210mm; height: 297mm; }.page-number { position: fixed; top: 10mm; right: 10mm; font-size: 12pt; color: #888; } }

image without styles

没有样式的图像

带有样式的图像

image with styles

Note: The CSS-based approach will only work in modern browsers that support the @media and @page rules. In older browsers, the page number will still be added by the browser using its default styles and positioning.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM