简体   繁体   English

有没有一种方法可以在每个浏览器上打印相同的网站?

[英]Is there a way to print a website the same across every browser?

I have a website which only consists of text (font-size and font-family). 我有一个仅包含文本(字体大小和字体系列)的网站。 The font-size is in mm and the fonts used are Times New Roman, Arial and Courier New. 字体大小以mm为单位,使用的字体为Times New Roman,Arial和Courier New。

When I print the website in all major browsers, every browser does something else. 当我在所有主要浏览器上打印网站时,每个浏览器都会执行其他操作。 I turned scaling off. 我关闭了缩放比例。

Am I doing something wrong or is it impossible to have a (very) simple webpage that looks the same on paper across every browser? 我是在做错什么,还是不可能有一个(非常)简单的网页,在每个浏览器上看起来都一样?

At the end of the day no. 在一天结束时。 You can get it close but it won't necessarily be the same. 您可以使其接近,但不一定相同。

EDIT: 编辑:

Since I got a downvote let me explain: There is no guaranteed way to make this work. 自从我投下赞成票以来,让我解释一下:没有保证的方法可以完成这项工作。 Every browser and version is going to be somewhat different and there's no way to guarantee the webpage will look or print the same in every browser. 每个浏览器和版本都会有所不同,并且无法保证网页在每个浏览器中的外观或打印效果都相同。

For printing, you can setup a specific stylesheet which the browser will use only when it is printing - here's some good resources: 对于打印,您可以设置一个特定的样式表,浏览器仅在打印时才使用它-这里有一些很好的资源:

http://www.webdesignerdepot.com/2010/01/10-tips-for-better-print-style-sheets/ - this is particularly good, especially the part about including the full link http://www.webdesignerdepot.com/2010/01/10-tips-for-better-print-style-sheets/-这特别好,尤其是包含完整链接的部分

a:link:after { content: " (" attr(href) ") "; }

http://coding.smashingmagazine.com/2011/11/24/how-to-set-up-a-print-style-sheet/ http://coding.smashingmagazine.com/2011/11/24/how-to-set-up-a-print-style-sheet/

There's some use of media queries there, but the basic way to include a specific stylesheets for printing is something like this: 那里有一些媒体查询的用法,但是包括特定样式表进行打印的基本方法是这样的:

<link rel="stylesheet" type="text/css" media="print" href="print.css" />

Good practice is to strip out as much as possible around the article and just give the user what they want - simple styles will also be easier to get working across browsers. 优良作法是在文章中尽可能多地去除文字,只给用户他们想要的东西-简单的样式也将更易于跨浏览器使用。

Start by adding a "reset css" to set all the browsers to a common starting point. 首先添加“重置CSS”以将所有浏览器设置为一个公共起点。 Searching for "reset css" should provide a variety. 搜索“重置CSS”应该提供多种选择。

Regarding your comment and as a partial answer, always use only free fonts. 关于您的评论和部分答案,请始终仅使用免费字体。 For example Times New Roman isn't (and as a linux user I don't have it) and should be preferred Liberation Serif (just like Arial should be replaced by Liberation Sans Narrow). 例如, Times New Roman不是(并且作为Linux用户,我没有),应该首选Liberation Serif(就像Arial应该由Liberation Sans Narrow代替一样)。

To have more stylistic freedom regarding the fonts, you could use Google Fonts . 要使字体具有更多的风格自由度,可以使用Google字体

Note also that both in browser display and in print, you can't really have exactly identical inputs in your form. 还要注意,在浏览器显示和打印中,表单中的输入实际上都不可能完全相同。

When I want to have a printing version exactly accorded to your need (including regarding pagination), I add a link building a PDF version of my page. 当我想要一个完全符合您需要的打印版本(包括关于分页)时,我添加了一个链接,用于构建页面的PDF版本。

When we needed a page that the user will print we had to make a completely separate html file, that used old table based layout, a reset.css , and there were still a few differences (like the margins were smaller in Chrome than on IE). 当我们需要用户打印的页面时,我们必须制作一个完全独立的html文件,该文件使用基于旧表的布局, reset.css ,并且仍然存在一些差异(例如Chrome的边距比IE的要小) )。 It is ugly (mainly because of the table based layout), but this way the sizes and layouts are at least identical. 这很丑陋(主要是因为基于表格的布局),但是这种方式的大小和布局至少是相同的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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