2016-03-22 14 views
2

A4サイズでhtmlページを印刷する必要があります。また、CSS、htmlと一緒に内容の本文を印刷し、メニューリスト、ヘッダー、フッター、ページの右側のメニューを無視したいリスト。A4ページにhtmlを印刷するとメディアが動作しない

これから始めて、単純なdivとclass noprintを紹介し、これを@mediaプリントに追加しましたが、その機能が動作していないようです。 noprintクラスは@mediaプリントの外で動作するので、正しいことが分かります。

また、私の要件は、標準のCtrl + Pのキーボードオプション

<style type="text/css"> 

    .standardStyle { 
     display:block; 
     width:200px; 
     height:150px; 
     padding:10px; 
     background-color:green; 
     margin:5px; 
    } 

    @media print{ 
    .noprint{ color:red;} 
    } 

</style> 

</head> 
<body> 

<div class="noprint standardStyle"> 
    this is test line.... 
</div> 

<div class="print standardStyle"> 
    this is test line.... 
</div> 

<div class="print standardStyle"> 
    this is test line.... 
</div> 

答えて

4

実行スニペットとCtrl + Pを打つを使用して、ブラウザから直接印刷することです赤色の線が表示されます。 スクリーンショット:

enter image description here

@media print { 
 
     .noprint { color:red; } 
 
}
<div class="noprint"> 
 
     this is test line..... 
 
</div>

+1

ありがとうございました.... – toxic

1
@media print 
{  
    .noprint{  
    display: none !important;   
    }  
} 
2

ほとんどのブラウザは、デフォルトでは背景色と背景画像を印刷しません。私はあなたが緑色の背景を欠いていると思います - これがその理由です。

通常、ブラウザの印刷ダイアログで調整できますが、強制的に背景を印刷するには、印刷に正しく表示されない設定に!importantを追加してみてください。

関連する問題