html @MEDIA 打印{},隐藏标记在打印中留下空白 [英] html @MEDIA print {}, to hide markup leaves blank space in the print

查看:34
本文介绍了html @MEDIA 打印{},隐藏标记在打印中留下空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i am using java script to print a selected area from in an html page..i used the @MEDIA print { .. to hide all headers, buttons and image from the page. It gets hidden but empty space remains. how do i align the print contents to print from the top of the page..

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

in the code the div top_part contains the buttons and text which i need to hide and it hides but how do i align the printable area from the top corner of the print

推荐答案

try

@MEDIA print {

#top_part{
display:none;
}

这篇关于html @MEDIA 打印{},隐藏标记在打印中留下空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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