当前位置:编程学习 > php >>

一段很小但很实用的CSS打印类(附例子及效果图)

答案:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
.tdp
{
    border-bottom: 1 solid #000000;
    border-left:  1 solid #000000;
    border-right:  0 solid #ffffff;
    border-top: 0 solid #ffffff;
}
.tabp
{
    border-color: #000000 #000000 #000000 #000000;
    border-style: solid;
    border-top-width: 2px;
    border-right-width: 2px;
    border-bottom-width: 1px;
    border-left-width: 1px;
}
</style>
</head>

<body onbeforeprint="printsub.style.display='none';" onafterprint="printsub.style.display='';">
<center><input type=button name="printsub" value=" 打印 " onclick="self.print();"><br></center>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0"  class="tabp">
  <tr align="center">
    <td height="25" colspan="3" class="tdp"><strong>计算机世界开发者俱乐部</strong></td>
  </tr>
  <tr>
    <td width="31%" height="26" align="center" class="tdp">PHP版</td>
    <td width="34%" align="center" class="tdp">DELPHI版</td>
    <td width="35%" align="center" class="tdp">JAVA版</td>
  </tr>
  <tr>
    <td height="40" colspan="3" class="tdp"><p>一段很小但很实用的CSS打印样式。一般带背景的表格在打印的时候,页面上看到的格线实际却打印不出来。其实不是打印不出来,是需要在打印的时候选择&quot;打印背景&quot;。1般不可能要求用户必须做这步。但用样式表&quot;画&quot;出来的格线在打印的时候就能得到&quot;所见即所打&quot;的效果。这效果当然不能和专业的打印控件如&quot;水晶报表&quot;想比,但满足普通的需求还是能够胜任的。</p></td>
  </tr>
  <tr>
    <td height="59" colspan="3" class="tdp">但在打印的时候,&quot;打印&quot;按纽不能被打印出来,所以就在&lt;body&gt;里用两个事件来控制它,这步很重要。</td>
  </tr>
  <tr>
    <td height="59" colspan="3" class="tdp">在使用这两个样式时,1个是让&lt;table&gt;的class=&quot;tabp&quot;,然后再它下面的每个&lt;td&gt;的class=&quot;tdp&quot;,&lt;tr&gt;不需要指定。记住,每个&lt;td&gt;都要指定一下。。。。</td>
  </tr>
  <tr>
    <td height="59" colspan="3" class="tdp">打印效果如图:(打印出的东东不包括菜单,只有下面的内容):</td>
  </tr>
</table>
</body>
</html>

上一个:一个翻页类
下一个:预定义变量之服务器变量:$_SERVER

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,