我正在尝试使用 css(@media print)更改打印文档的样式,并定义了一个简单的样式来在打印时更改标题字体大小。然而,印刷媒体的风格根本没有改变。谁能告诉我哪里出错了?谢谢!这就是我所做的
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="testmediacss.aspx.cs" Inherits="PrintDemo1.testmediacss" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css" >
@media print { body {font: 50pt Arial;} h1 {font-size: 138pt;} h2 {font-size: 15pt; color: #000;} }
</style>
<script type="text/javascript" language="javascript">
function CallPrint(strid){
var prtContent = document.getElementById(strid);
var WinPrint = window.open('', '', 'letf=1000,top=1000,width=1000,height=500,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="divprint">
<p>hello this is the part to be printed in the printer.</p>
<h1>hello world</h1>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="CallPrint('divprint');" />
</form>
</body>
</html>