我可以从我的打印 css 中删除 URL,以便不打印网址吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2192806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I remove the URL from my print css, so the web address doesn't print?
提问by Mark
I have written some stylesheets - including a print.css - and it's working fine.
我写了一些样式表 - 包括一个 print.css - 它工作正常。
I'd like to remove the URL from printing out on each of the pages. I am beginning to wonder if it is impossible. Is there an element/option that I can set to display:none to do this?
我想从每个页面上的打印中删除 URL。我开始怀疑这是否不可能。是否有可以设置为 display:none 的元素/选项来执行此操作?
The reason is that the specific pages that have a 'normal' and 'print' stylesheet have been specially formatted so when printed, it forms a meaningful booklet. Therefore the URL is irrelevant.
原因是具有“正常”和“打印”样式表的特定页面已被特殊格式化,因此在打印时,它形成了一个有意义的小册子。因此,URL 无关紧要。
回答by Daniel Gross
In Firefox, https://bug743252.bugzilla.mozilla.org/attachment.cgi?id=714383(view page source :: tag HTML).
在 Firefox 中,https: //bug743252.bugzilla.mozilla.org/attachment.cgi ?id=714383(查看页面源 :: 标记 HTML)。
In your code, replace <html>
with <html moznomarginboxes mozdisallowselectionprint>
.
在您的代码中,替换<html>
为<html moznomarginboxes mozdisallowselectionprint>
.
In others browsers, I don't know, but you can view http://www.mintprintables.com/print-tips/header-footer-windows/
在其他浏览器中,我不知道,但您可以查看http://www.mintprintables.com/print-tips/header-footer-windows/
回答by Pekka
Sadly, no. The header and footer are generated by the browser. Only the end-user can change the footer - it might be an idea to give the user a step-by-step for each browser what to do. See for example herefor a set of illustrated walk-throughs for windows based browsers.
可悲的是没有。页眉和页脚由浏览器生成。只有最终用户可以更改页脚 - 为用户提供每个浏览器的逐步操作可能是一个想法。例如,请参见此处的一组图解说明,用于基于 Windows 的浏览器。
The only alternative I know of is generating PDFs, with which you have full control over the printed output.
我所知道的唯一替代方法是生成 PDF,您可以完全控制打印输出。
回答by Muhammad Fahad
Use that code.that will help to solve your problem
使用该代码。这将有助于解决您的问题
@media print
{
@page { margin: 0; }
body { margin: 1.6cm; }
}
回答by Darshan Kathiriya
@media print
{
a[href]:after { content: none !important; }
img[src]:after { content: none !important; }
}
回答by mtchuente
you can try this in the stylesheet:
你可以在样式表中试试这个:
@page{size:auto; margin-bottom:5mm;}
But this also removes the page number
但这也删除了页码
回答by awe
This solutionwill do the trick in Chrome and Opera by setting margin to 0 in a css @page directive. It will not (currently) work for other browsers though...
此解决方案将通过在 css @page 指令中将边距设置为 0 来实现 Chrome 和 Opera 中的技巧。虽然它(目前)不适用于其他浏览器......
回答by Simon Whitaker
It depends on your web browser. If you're using Firefox you can adjust or turn off those header and footer lines (URL, page number, etc) by going into File > Page Setupthen clicking the Margins & Header/Footertab.
这取决于您的网络浏览器。如果您使用的是 Firefox,您可以通过进入“文件”>“页面设置”然后单击“边距和页眉/页脚”选项卡来调整或关闭这些页眉和页脚行(URL、页码等)。
回答by Anthony
The headers and footers for printing from browsers is, sadly, a browser preference, not a document-level element that you can style. Refer to my very similar questionfor further workarounds and disappointment.
遗憾的是,用于从浏览器打印的页眉和页脚是浏览器首选项,而不是您可以设置样式的文档级元素。有关进一步的解决方法和失望,请参阅我非常相似的问题。
回答by Beat Bolli
If I understand you correctly, you talk about the page headers and footers. They are printed by the browser. They are not part of your HTML content, so you can't influence them directly.
如果我理解正确,你会谈论页眉和页脚。它们由浏览器打印。它们不是您的 HTML 内容的一部分,因此您不能直接影响它们。
Show your users how to disable headers and footers in the ?Page setup...? dialog.
向您的用户展示如何在“页面设置...”中禁用页眉和页脚。对话。
回答by Aniruddha Sathe
Historically, it's been impossible to make these things disappear as they are user settings and not considered part of the page you have control over.
从历史上看,让这些东西消失是不可能的,因为它们是用户设置,不被视为您可以控制的页面的一部分。
http://css-discuss.incutio.com/wiki/Print_Stylesheets#Print_headers.2Ffooters_and_print_margins
http://css-discuss.incutio.com/wiki/Print_Stylesheets#Print_headers.2Ffooters_and_print_margins
However, as of 2017, the @page at-rule has been standardized, which can be used to hide the page title and date in modern browsers:
但是,截至 2017 年,@page at 规则已标准化,可用于在现代浏览器中隐藏页面标题和日期:
@page { size: auto; margin: 0mm; }
@page { 大小:自动;边距:0mm;}
Credit to Vigneswaran S for this tip.
此提示归功于 Vigneswaran S。