日期:2011-04-29  浏览次数:20767 次

大家经常遇到再ie中打印表格时需要隐藏一些不需要打印的对象,比如说按钮,输入框,或者希望莫个表格显示的时候表格线是由颜色的,而打印的时候只需要有粗细之分,其实在css中可以设定在打印或者显示的不同样式,最近作了一个应用(实属逼上梁山),可以得到以上效果,下面是我的样式表。。。。
<style type="text/css" media=print>  主要是media选项对照下面的那一个style一起看
.noprint{visibility:hidden}
        span.double {BORDER-BOTTOM-STYLE: double; BORDER-LEFT-STYLE: double;
        BORDER-RIGHT-STYLE: double; BORDER-TOP-STYLE: double; COLOR: mediumblue;
        CURSOR: hand; FONT-SIZE: 12pt; HEIGHT: 22px; LEFT: 314px; TEXT-ALIGN: center;
        WIDTH: 96px}
        select.sb{Z-INDEX: 121; LEFT:0px;WIDTH: 90px; POSITION: absolute;
        HEIGHT: 170px}
        span.tab{LEFT:40px;WIDTH: 900px; POSITION: relative; TOP: 0px; HEIGHT: 225px}
        table{BORDER-RIGHT: black medium inset; BORDER-TOP: black medium inset; BORDER-LEFT: black medium inset; WIDTH: 900px; BORDER-BOTTOM: black medium inset; HEIGHT: 31px;POSITION: absolute}
        tr.col0{BORDER-RIGHT: thick inset; BORDER-TOP: thick inset; FONT-WEIGHT: bold; FONT-SIZE: 15px; BORDER-LEFT: thick inset; BORDER-BOTTOM: 10px ; FONT-FAMILY: 宋体; BACKGROUND-COLOR: blue; TEXT-ALIGN: center}
        tr.tr1{}
        td.td0{WIDTH: 120px; TEXT-ALIGN: center;height:30px;}
        td.td1{WIDTH: 330px; TEXT-ALIGN: right}
        td.td2{WIDTH: 70px;TEXT-ALIGN: right}
        td.td3{WIDTH: 330px;TEXT-ALIGN: right}
</style>

<style media=screen>主要是media选项对照上面的那一个style一起看
        span.double {BORDER-BOTTOM-STYLE: double; BORDER-LEFT-STYLE: double; BORDER-RIGHT-STYLE: double; BORDER-TOP-STYLE: double; COLOR: mediumblue;
        CURSOR: hand; FONT-SIZE: 12pt; HEIGHT: 22px; LEFT: 314px; TEXT-ALIGN: center;
        WIDTH: 96px}
        select.sb{Z-INDEX: 121; LEFT:0px;WIDTH: 90px; POSITION: absolute;
        HEIGHT: 170px}
        span.tab{LEFT:154px;WIDTH: 900px; POSITION: relative; TOP: 30px; HEIGHT: 225px}
        table{BORDER-RIGHT: blue groove; BORDER-TOP: blue groove; BORDER-LEFT: blue groove; WIDTH: 900px; BORDER-BOTTOM: blue groove; POSITION: absolute}
        tr.col0{BORDER-RIGHT: red thick inset; BORDER-TOP: red thick inset; FONT-WEIGHT: bold; FONT-SIZE: 15px; BORDER-LEFT: red thick inset; COLOR: white; BORDER-BOTTOM: yellow 10px solid; FONT-FAMILY: 宋体; BACKGROUND-COLOR: blue; TEXT-ALIGN: center}
        tr.tr1{BORDER-BOTTOM: fuchsia inset}
        td.td0{WIDTH: 120px; BORDER-LEFT-STYLE: none; TEXT-ALIGN: center;BORDER-BOTTOM-STYLE: none}
        td.td1{WIDTH: 330px;BORDER-LEFT: blue thin solid; TEXT-ALIGN: right}
        td.td2{WIDTH: 70px;BORDER-TOP-STYLE: inset; BORDER-RIGHT-STYLE: inset; BORDER-LEFT-STYLE: inset; TEXT-ALIGN: right; BORDER-BOTTOM-STYLE: inset}
        td.td3{WIDTH: 330px;BORDER-TOP-STYLE: inset; BORDER-RIGHT-STYLE: inset; BORDER-LEFT-STYLE: inset; TEXT-ALIGN: right; BORDER-