日期:2014-05-17  浏览次数:20721 次

我想web里内容 某个内容打印时可以显示,其他不能显示 怎么实现?帮看看我的代码
<style>
@media   print   {  

.ptnY   {display: ' '}  
.ptn   {display:none;}  
}  
</style>
<div   align= "center "   class= "ptn ">

<table   width= "184 "     border= "1 "   >
         
<tr   >
<td   width= "65 "   height= "24 "       >   项目1 </td>
<td   width= "56 "   height= "24 "     class= "ptnY "   > AAA </td>
</tr>

<tr   >
<td     height= "24 "       > 项目2 </td>
<td     height= "24 "   class= "ptnY "   > BBB </td>
</tr>

    </table>

</div>

=============
<div   align= "center "   class= "ptn ">   隐藏所有内容
<td     height= "24 "   class= "ptnY "   > BBB </td>   想打印时显示     但实际不行   怎么办


------解决方案--------------------
皮之不存,毛将焉附?

改成下面的样子:

<style>
@media screen {
.ptnY {display: ' '}
.ptnN {display:none;}
}
</style>
<table width= "184 " border= "1 " >
<tr >
<td width= "65 " height= "24 " class= "ptnN "> 项目1 </td>
<td width= "56 " height= "24 " class= "ptnY " > AAA </td>
</tr>
<tr >
<td height= "24 " class= "ptnN "> 项目2 </td>
<td height= "24 " class= "ptnY " > BBB </td>
</tr>
</table>


------解决方案--------------------
看来楼主没有明白我的意思:皮之不存,毛将焉附?在你最上面的html中,div都不显示了,div中的部分内容还显示出来吗?

<style>
@media print {
.ptnY {display:block;}
.ptnN {visibility:hidden;/*如果不保留显示的空白,则使用display:none;*/}
}
</style>
<table width= "184 " border= "1 " >
<tr >
<td width= "65 " height= "24 " class= "ptnN "> 项目1 </td>
<td width= "56 " height= "24 " class= "ptnY " > AAA </td>
</tr>
<tr >
<td height= "24 " class= "ptnN "> 项目2 </td>
<td height= "24 " class= "ptnY " > BBB </td>
</tr>
</table>