求教CSS高手,firefox和IE的打印预览

bitsbird 2010-01-28 10:32:45
以下代码
在IE中打印预览中,显示两页,并可以翻页,
在firefox中打印预览,显示只有一页,不可以翻页。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html >
<head><title></title>
</head><body>
<div style="position: relative; width:100%;height:100%;"><div

style="position:absolute;left:234px;top:54px;width:607px;height:32px;overflow:hidden;"><tabl

e border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td style="font

-size:27px;font-family:Arial;word-wrap:break-word;border-width:0px;border-

style:solid;border-color:black;text-align:center;vertical-align:top;"><b>Work

orders</b></td></tr></table></div><div

style="position:absolute;left:37px;top:96px;width:66px;height:14px;overflow:hidden;"><table

border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td style="font-

size:11px;font-family:Arial;word-wrap:break-word;border-width:0px;border-style:solid;border

-color:black;text-align:left;vertical-align:top;"><b>WO No.</b></td></tr></table></div>

<div style="page-break-before:always" id="pb1"></div>
<div style="position:relative;width:100%;height:100%" id="bk1"><div

style="position:absolute;left:234px;top:54px;width:607px;height:32px;overflow:hidden;"

id="o1"><table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td

style="font-size:27px;font-family:Arial;word-wrap:break-word;border-width:0px;border-

style:solid;border-color:black;text-align:center;vertical-align:top;"><b>Work

orders</b></td></tr></table></div><div

style="position:absolute;left:37px;top:96px;width:66px;height:14px;overflow:hidden;"><table

border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"><tr><td style="font-

size:11px;font-family:Arial;word-wrap:break-word;border-width:0px;border-style:solid;border

-color:black;text-align:left;vertical-align:top;"><b>WO No.</b></td></tr></table></div>
</body>
</html>
...全文
394 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
狼王_ 2010-01-29
  • 打赏
  • 举报
回复
这代码
lovexilove 2010-01-29
  • 打赏
  • 举报
回复
up
wendy_fw 2010-01-29
  • 打赏
  • 举报
回复
幫頂.
罗纳尔迪尼奥 2010-01-29
  • 打赏
  • 举报
回复
如果要设置两页打印,那么不要设置position:absolute属性 例如下面就行

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html >
<head> <title> </title>
</head> <body>
<div style="position: relative; width:100%;height:100%;"> <div

style="width:607px;height:32px;overflow:hidden;"> <tabl

e border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"> <tr> <td style="font

-size:27px;font-family:Arial;word-wrap:break-word;border-width:0px;border-

style:solid;border-color:black;text-align:center;vertical-align:top;"> <b>Work

orders </b> </td> </tr> </table> </div> </div>

<div style="page-break-before:always;">·················这个是打印分割···············</div>

<div

style="width:66px;height:14px;overflow:hidden;"> <table

border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"> <tr> <td style="font-

size:11px;font-family:Arial;word-wrap:break-word;border-width:0px;border-style:solid;border

-color:black;text-align:left;vertical-align:top;"> <b>WO No. </b> </td> </tr> </table> </div>

<div id="pb1"> </div>
<div style="position:relative;width:100%;height:100%" id="bk1"> <div

style="width:607px;height:32px;overflow:hidden;"

id="o1">
<table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"> <tr> <td

style="font-size:27px;font-family:Arial;word-wrap:break-word;border-width:0px;border-

style:solid;border-color:black;text-align:center;vertical-align:top;"> <b>Work

orders </b> </td> </tr> </table> </div> </div>
<div

style="width:66px;height:14px;overflow:hidden;">
<table

border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr>
<td style="font-

size:11px;font-family:Arial;word-wrap:break-word;border-width:0px;border-style:solid;border

-color:black;text-align:left;vertical-align:top;"><b>WO No. </b> </td>
</tr>
</table>
</div>
</body>
</html>
罗纳尔迪尼奥 2010-01-29
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html >
<head> <title> </title>
</head> <body>
<div style="position: relative; width:100%;height:100%;"> <div

style="position:absolute;left:234px;top:54px;width:607px;height:32px;overflow:hidden;"> <tabl

e border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"> <tr> <td style="font

-size:27px;font-family:Arial;word-wrap:break-word;border-width:0px;border-

style:solid;border-color:black;text-align:center;vertical-align:top;"> <b>Work

orders </b> </td> </tr> </table> </div></div> <div

style="position:absolute;left:37px;top:96px;width:66px;height:14px;overflow:hidden;"> <table

border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"> <tr> <td style="font-

size:11px;font-family:Arial;word-wrap:break-word;border-width:0px;border-style:solid;border

-color:black;text-align:left;vertical-align:top;"> <b>WO No. </b> </td> </tr> </table> </div>

<div id="pb1"> </div>
<div style="position:relative;width:100%;height:100%" id="bk1"> <div

style="position:absolute;left:233px;top:51px;width:607px;height:32px;overflow:hidden;"

id="o1">
<table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"> <tr> <td

style="font-size:27px;font-family:Arial;word-wrap:break-word;border-width:0px;border-

style:solid;border-color:black;text-align:center;vertical-align:top;"> <b>Work

orders </b> </td> </tr> </table> </div></div> <div

style="position:absolute;left:37px;top:96px;width:66px;height:14px;overflow:hidden;"> <table

border="0" width="100%" height="100%" cellpadding="0" cellspacing="0"> <tr> <td style="font-

size:11px;font-family:Arial;word-wrap:break-word;border-width:0px;border-style:solid;border

-color:black;text-align:left;vertical-align:top;"> <b>WO No. </b> </td> </tr> </table> </div>
</body>
</html>

首先你这个页面丢失一些DIV结束标签,其次取消这个样式定义style="page-break-before:always" 现在我测试都是只有一页,统一了,不知道你想要什么效果
jlj84237485 2010-01-29
  • 打赏
  • 举报
回复
UP
bychgh 2010-01-29
  • 打赏
  • 举报
回复
帮顶
itliyi 2010-01-29
  • 打赏
  • 举报
回复
学习
bitsbird 2010-01-29
  • 打赏
  • 举报
回复
如果要设置两页打印,那么不要设置position:absolute属性
-----------------------------------------------
设置绝对当然是为了定位第二页的页面元素显示位置。
my176527627 2010-01-29
  • 打赏
  • 举报
回复
欢迎做ASP.NET(C#)技术的朋友遇到技术问题来本群交流,群友会不定期讲解相关技术,一37078937(满),二群37078867(满),超级群42656401,请按照群要求修改工作地名-昵称,群会不定期清理不发言交流的,不改名的,保持群内新鲜血液,希望大家互相交流,共同提高技术!谢谢
wosizy 2010-01-29
  • 打赏
  • 举报
回复
需要加上两个关键的CSS 才能和IE 的效果一样
<style media="print">
.Noprint { DISPLAY: none }
.PageNext{ PAGE-BREAK-AFTER: always }
</style>第一个在不需要打印的标签上添加(子标签也将不被打印),第二个在需要换行的标签处添加(该标签所表示的内容将在当前打印的一页内)


cs5276 2010-01-28
  • 打赏
  • 举报
回复
这布局。。有点太乱了

62,265

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧