【问题标题】:html @MEDIA print {}, to hide markup leaves blank space in the printhtml @MEDIA print {},隐藏标记在打印中留下空白
【发布时间】:2013-08-26 04:36:47
【问题描述】:

我正在使用 java 脚本从 html 页面中打印选定区域。我使用 @MEDIA print { .. 隐藏页面中的所有标题、按钮和图像。它被隐藏了,但仍然存在空白空间。如何对齐打印内容以从页面顶部打印..

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<style type="text/css">
@MEDIA print {
    #top_part{
    visibility:hidden;
    }
    #print{
    margin-top: 5px;
        }
    }
    </style>
</head>
<body>
<div id="top_part">
<button onclick="window.print();">print</button>
hello <br/>
<br/><br/><br/><br/><br/>
test if the printer avoids this content
<br/>

打印这个..

</body>
</html>

在代码中,div top_part 包含我需要隐藏的按钮和文本,但它隐藏了,但我如何从打印的顶角对齐可打印区域

【问题讨论】:

  • visibility:hidden; 保留元素空间。如果您不想要那个空间,请使用display:none
  • 你需要关闭你的&lt;div&gt;标签。
  • visibility: hidden 故意为元素留出空间(它们是不可见的,但仍然存在)。试试display: none
  • 感谢显示:没有办法解决

标签: javascript html


【解决方案1】:

试试

@MEDIA print {

#top_part{
display:none;
}

【讨论】:

    猜你喜欢
    • 2019-01-30
    • 1970-01-01
    • 2020-07-27
    • 2014-07-27
    • 1970-01-01
    • 2012-08-22
    • 2017-10-01
    • 2023-04-03
    • 1970-01-01
    相关资源
    最近更新 更多