gpt4 book ai didi

html - 在 A4 页面上打印 html,媒体不工作

转载 作者:太空宇宙 更新时间:2023-11-04 14:13:11 25 4
gpt4 key购买 nike

我需要打印 A4 尺寸的 html 页面,另外我想打印内容正文以及 css、html 并忽略菜单列表、页眉、页脚和页面右侧菜单列表。

首先,我介绍了简单的 div 和 noprint 类,并将其添加到@media print 中,但它似乎不起作用。 noprint 类在@media print 之外工作,所以我知道它是正确的。

另外我的要求是使用标准的 Ctrl+P 键盘选项直接从浏览器打印

<style type="text/css">

.standardStyle {
display:block;
width:200px;
height:150px;
padding:10px;
background-color:green;
margin:5px;
}

@media print{
.noprint{ color:red;}
}

</style>

</head>
<body>

<div class="noprint standardStyle">
this is test line....
</div>

<div class="print standardStyle">
this is test line....
</div>

<div class="print standardStyle">
this is test line....
</div>

最佳答案

运行代码片段并按 Ctrl+P ,您将看到红色的线。截图:

enter image description here

@media print {
.noprint { color:red; }
}
<div class="noprint">
this is test line.....
</div>

关于html - 在 A4 页面上打印 html,媒体不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36160140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com