隐藏除一个div以外的所有元素以进行打印视图

编程入门 行业动态 更新时间:2024-10-28 07:28:54
本文介绍了隐藏除一个div以外的所有元素以进行打印视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的打印样式有以下CSS:

I have the following CSS for my print style:

* { display:none; } #printableArea { display:block; }

我希望这可以隐藏所有元素,并且只显示printableArea,但是所有都被隐藏了.在打印视图中,我得到的只是一个空白页.

I expected this to hide all elements, and only show the printableArea, however everything gets hidden. In print view, all I get is a blank page.

我已将其正确包含在HEAD中,并在此特定样式表上包含media="print".

I have it included properly in the HEAD, with media="print" on this particular stylesheet.

推荐答案

如果未显示元素,则不会显示其任何子元素(无论其显示属性设置为什么).

If an element is not displayed, then none of its children will be displayed (no matter what their display property is set to).

*与<html>元素匹配,因此整个文档都被隐藏了.

* matches the <html> element, so the entire document is hidden.

您需要对隐藏的内容更具选择性.

You need to be more selective about what you hide.

更多推荐

隐藏除一个div以外的所有元素以进行打印视图

本文发布于:2023-06-06 05:51:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/534707.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   素以   div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!