[英]display content from specific div on print
I want to print some content from firefox. 我想从Firefox打印一些内容。 I already have inside html page <div id="printContent"></div>
which is hidden by default. 我已经在html页面<div id="printContent"></div>
,该页面默认为隐藏。 Using css I display this div with injected content on printing like 使用CSS我在打印时显示此div并注入内容
@media print {
#printContent{
display:block;
}
}
but on print preview I'm getting some other page div, not just this #printContent
. 但是在打印预览中,我得到了其他页面div,而不仅仅是这个#printContent
。 What should I do to get only #printContent
on firefox print preview? 我应该怎么做才能在firefox打印预览上仅获取#printContent
?
Hide the other content using display:none in media selector - I'd suggest your #printContent div be a child of body, then you can 使用display:none在媒体选择器中隐藏其他内容-建议您将#printContent div设为body的子代,然后
@media print {
body>* {
display:none !important;
}
body>div#printContent{
display:block !important;
}
}
edit: added !important - depending on other CSS you may or may not need !important
编辑:添加了!important-取决于您是否需要!important
其他CSS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.