我想用css打印一个div。当我申请inline css
时,它与我一起工作,但external and internal css
它不起作用。下面是我的代码,
<script src="jquery.jqprint.0.3.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(function() {
$("#PrintButton").click( function() {
$('#divToPrint').jqprint();
return false;
});
});
</script>
<style type="text/css">
@media screen,print
{
.test {background:#0F0; width:500px; height:200px;}
}
</style>
<input id="PrintButton" type="button" name="Print" value="Print" />
<div id="divToPrint" class="test">
Print Me, I'm in DIV
</div>
我已经尝试过您的代码,它似乎在外部 CSS 上运行良好。
<html>
<head>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.jqprint-0.3.js" type="text/javascript"></script>
<link rel="stylesheet" href="test.css">
<script language="javascript" type="text/javascript">
$(function() {
$("#PrintButton").click( function() {
$('#divToPrint').jqprint();
return false;
});
});
</script>
</head>
<body>
<input id="PrintButton" type="button" name="Print" value="Print" />
<div id="divToPrint" class="test">
Print Me, I'm in DIV
</div>
<body>
</html>
和外部CSS文件名:测试.css
@media screen,print
{
.test {
background:#0F0; width:500px; height:200px;
}
}