预期效果:
原代码:
/* 打印样式*/
@media print {
#contendmidd tr{
line-height: 13px;
}
td.tdStyle {
color: red !important;
}
.width100{
font-size: 12px;
width: 20%;
text-align: center;
font-family:cursive;
}
}
分析:
@media print中字体大小,行高,宽度属性均起作用,只有颜色设置后无任何变化,查阅文档后发现在浏览器中重写了颜色为黑色,若想改变颜色,需重写浏览器覆盖的颜色代码,修改如下:
正确代码
/* 打印样式*/
@media print {
#contendmidd tr{
line-height: 13px;
}
td.tdStyle {
background: transparent !important;
color: red !important; // Black prints faster: h5bp.com/s
box-shadow: none !important;
text-shadow: none !important;
}
.width100{
font-size: 12px;
width: 20%;
text-align: center;
font-family:cursive;
}
}
测试即可正常显示颜色