【问题标题】:Print from Chrome is not centered从 Chrome 打印未居中
【发布时间】:2011-09-12 18:04:51
【问题描述】:

我创建了我想从浏览器打印的简单页面。 我把我能找到的所有口哨放在我的标题和图片的中心。

<html>
<head>
    <link rel="stylesheet" href="print.css" type="text/css" media="print" />
    <!-- print.css is empty -->
</head>
<body style="text-align: center; margin: 0 auto;">
    <div>
        <div style="font-size:48pt">
            Pretty Long-Long-Long Title
        </div>
        <img src="content/images/sample.jpg" style="width:80%"/>
    </div>
</body>
</html>

页面在所有浏览器中看起来都很好并且居中。
该页面在 IE 和 Firefox 中打印良好(居中),但在 Chrome 中,整个正文框是左对齐的,并且比页面宽度小得多。
是否有任何提示可以帮助从 Chrome 打印居中的标题/图像?


问题解决了。
问题出在 Chrome 本身。更准确地说,在使用 Chrome PDF Writer 插件的 Print Preview 中。看起来 Chrome PDF Writer 无法识别页面大小并且没有任何页面设置设置。我禁用了 Chrome 的打印预览,安装了 Adob​​e 的 PDF 打印机,我的原始代码片段打印一切正常。

【问题讨论】:

    标签: html css google-chrome printing


    【解决方案1】:

    试试这个

    <body>
        <div align="center" style="text-align:center;">
            <div style="font-size:48pt">
                Pretty Long-Long-Long Title
            </div>
            <img src="content/images/sample.jpg" style="width:80%"/>
        </div>
    </body>
    

    要么

    <div align="center" style="text-align:center;">
    

    <div style="text-align:center;margin:0 auto;">
    

    在 chrome 中为我工作,打印为 pdf

    【讨论】:

    • #1 使左对齐 #2 的标题与我原来的方式相同。也许有一些我不知道的 Chrome 设置?
    • 我认为 Chrome 提取了正文内容,因此应用到它的任何样式都会被删除。我无法确认确实是这样,但似乎是这样。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-14
    • 2021-11-10
    • 1970-01-01
    相关资源
    最近更新 更多