打印修改后的网页而不显示它

发布于 2024-11-07 19:43:53 字数 1193 浏览 11 评论 0原文

我正在尝试在电子商务产品页面上实现“打印此页面”。它将没有不必要的部分,如顶部导航、页脚、添加到购物车按钮等。我希望它像 target.com 一样工作 <一href="http://www.target.com/Avalon-Vitamin-Moisture-Plus-Lotion/dp/B00120ZAYI/ref=sr_1_13?ie=UTF8&searchView=grid5&keywo rds=维生素&fromGsearch=true&sr=1-13&qid=1305580954&rh=&searchRank=target104545&id=Avalon%20Vitamin%20M oisture%20Plus%20Lotion&node=1038576|1287991011&searchSize=30&searchPage=1&searchNodeID=1038576|1287991011&s searchBinNameList=subjectbin%2Cprice%2Ctarget_com_primary_color-bin%2Ctarget_com_size-bin%2Ctarget_com_brand-bin&frombrowse=0" rel="nofollow">http://www.target.com/Avalon-Vitamin-Moisture-Plus-Lotion/dp/B00120ZAYI/ref=sr_1_13?ie=UTF8&searchView=grid5& ;关键字=维生素&fromGsearch=true&sr=1-13&qid=1305580954&rh=&searchRank=target104545&id=Avalon%20Vitamin% 20Moisture%20Plus%20Lotion&node=1038576|1287991011&searchSize=30&searchPage=1&searchNodeID=1038576|1287991011&s searchBinNameList=subjectbin%2Cprice%2Ctarget_com_primary_color-bin%2Ctarget_com_size-bin%2Ctarget_com_brand-bin&frombrowse=0

如果您尝试打印它,则只会打印必要的内容。我很困惑如何实施它。我是否应该创建产品页面的修改版本并打印它而不向用户显示?请指教。

I'm trying to implement "print this page" on an e-commerce product page. It will be without needless sections like top navigation, footer, add to cart button etc. I want it to work like target.com
http://www.target.com/Avalon-Vitamin-Moisture-Plus-Lotion/dp/B00120ZAYI/ref=sr_1_13?ie=UTF8&searchView=grid5&keywords=vitamins&fromGsearch=true&sr=1-13&qid=1305580954&rh=&searchRank=target104545&id=Avalon%20Vitamin%20Moisture%20Plus%20Lotion&node=1038576|1287991011&searchSize=30&searchPage=1&searchNodeID=1038576|1287991011&searchBinNameList=subjectbin%2Cprice%2Ctarget_com_primary_color-bin%2Ctarget_com_size-bin%2Ctarget_com_brand-bin&frombrowse=0

If you try to print it, only essential content gets printed. I'm confused how to implement it. Should I create a modified version of product page and print it without displaying it to a user? Please advise.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红玫瑰 2024-11-14 19:43:54

您可以设置一个自定义 CSS 页面,其中包含页眉、导航、页脚或您喜欢隐藏的任何内容,这样当用户单击打印时,Web 浏览器会查看打印 CSS 并按照您希望的方式执行操作。

例子是:

在 HTML

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

属性“media”下,只有在打印出来时才会使用 print。

在 main.css 的 CSS 中,可能看起来像...

header { font-size: 32px; }
nav { font-size: 14px; }
footer { font-size: 10px; text-align: center; }

在 print.css 的 CSS 中,它可能看起来像...

header { display: none; }
nav { display: none; }
footer { display: none; }

基本上,复制您正在使用的 CSS,然后设置 display: none;您不想打印的内容。

You're able to set a custom CSS page that has the header, navigation, footer or whatever you like hidden so when the user clicks print, the web browser looks at the print css and acts how you want it to.

Example of this is:

In the HTML

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

Under the attribute "media", print will only be used when printing it out.

In the CSS for main.css, could look like..

header { font-size: 32px; }
nav { font-size: 14px; }
footer { font-size: 10px; text-align: center; }

In the CSS for print.css, it can look like...

header { display: none; }
nav { display: none; }
footer { display: none; }

Basically, make a duplicate of the CSS you're using and just set display: none; to what you don't want to have printed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文