简体   繁体   English

@media印刷品显示:没有任何作用

[英]@media print display:none isn't working

I have tried for over 3 weeks now with different implementations trying to get the right section to not display, and have the left section display at full width. 我已经尝试了3个多星期,采用了不同的实现方式,试图使右侧部分不显示,而左侧部分以全宽显示。 Given that my research shows there is no easy or streamlined way to quickly render Print views without reviewing the print preview, I am asking for some help to figure this out. 鉴于我的研究表明,没有简单或精简的方法就可以快速渲染“打印”视图而不查看打印预览,因此我需要一些帮助来解决这个问题。

the print media css that is not working is this: 不起作用的打印介质css是这样的:

#gc {
    width: 100%;
}
#asideTrack {
/*      width: 100%;*/
    display: none;
}
.asideTrack {
/*      width: 100%;*/
    display: none;
}
.slideAside {
/*      width: 100%;*/
    display: none;
}
#slideAside {
    display:none
}

Any suggestions? 有什么建议么?

In CSS lower rule overwrites the top if they have the same priority (depending on selector) 在CSS中,如果优先级相同,则较低的规则会覆盖顶部(取决于选择器)

You write your common css not in @media block, and it is lower then your @media print block, so it overwrites your @media print styles. 您不在@media块中编写普通的CSS,并且它比@media打印块低,因此它会覆盖您的@media打印样式。 For example, it is cause why in print preview your left block has width 74% (because this rule is lower then rule of @media print block where you say it is 100%). 例如,这就是为什么在打印预览中您的左图块具有74%的宽度(因为此规则比@media打印图块的规则低,因为您说它是100%)。

I hope it is helpful. 希望对您有所帮助。

Solutions 解决方案

  1. In your css file you may place media print block to the end of file. 在您的css文件中,您可以将媒体打印块放在文件末尾。
  2. Add !important directives to some rules in media print block. 在介质打印块中的某些规则上添加!important指令。 ie: p { color: red !important; 即:p {颜色:红色!重要; } }
  3. Place your special css for screen in media screen block. 将特殊的CSS屏幕放置在媒体屏幕块中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM