javascript - html @MEDIA print {},隐藏标记,在打印中留下空白

标签 javascript html

我正在使用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 包含我需要隐藏的按钮和文本,它隐藏了,但如何从打印的顶 Angular 对齐可打印区域

最佳答案

尝试

@MEDIA print {

#top_part{
display:none;
}

关于javascript - html @MEDIA print {},隐藏标记,在打印中留下空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18433421/

相关文章:

Internet Explorer 中的 Javascript 故障

html - 禁用 iframe 中的所有样式

java - 如何获取Jsoup中特定html元素的内容?

html - 元素上的 css 样式不起作用

javascript - 未捕获的 TypeError : this. 时间戳不是函数

javascript - 如何使用jquery从文件输入类型获取文件名而不需要表单提交

javascript - 将元素从开始位置动画到另一个元素的位置

javascript - AngularJS 和 ngStorage 记住设置?

html - 最小化窗口时缺少文本

html - 多个 Logo 之间的 CSS 元素符号点