我正在尝试用 HTML 实现打印功能。我知道我可以打印整页window.print()
,但是如何只打印特定的页面元素呢?例如一个特定的<DIV>Some text to print</DIV>
.
您可以使用打印特定的 CSS 样式表并隐藏除您想要打印的内容之外的所有内容。
<div class="no-print">I won't print</div><div class="something-else">I will!</div>
只是no-print
类将被隐藏,但任何具有打印类的内容都会显示。
<style type="text/css" media="print">
.no-print { display: none; }
</style>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)