CSS:隐藏的元素仍然占据打印输出的空间 [英] CSS: Hidden elements still take up space on printed output

查看:51
本文介绍了CSS:隐藏的元素仍然占据打印输出的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CSS仅打印页面的一部分:

I'm using css to only print a section of a page:

    body {
 visibility:hidden;
    }
    .print {
     visibility:visible;
     background-color: white;
     margin: 0;
    } 

我要打印的元素上方的部分已正确隐藏在打印输出中,但是仍然占用空间.我通过列出一长串垂直单词来进行测试.在打印输出中,出现相同区域的空白而没有单词,然后出现元素输出.仅在chrome和mozilla上会发生此问题.我还测试了浏览器的边距选项,这不是问题.

The section above the element I want to print gets properly hidden in the print output, however it still takes up the area of space. I tested this by making a long vertical list of words. In the print output the same area of white space occurs without the words and then the element output occurs. This problem occurs on chrome and mozilla only. I've also tested the browser's margin options and that's not the problem.

有什么想法吗?

推荐答案

您要 display:none 而不是 visibility:hidden .后者使元素不可见,但不会将其从文档流中删除.

You want display:none not visibility:hidden. The latter makes the element invisible, but doesn't remove it from the document flow.

这篇关于CSS:隐藏的元素仍然占据打印输出的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆