2014-02-13 118 views
0

我有這個網頁打開一個iFrame,寬度爲900px。在iFrame中有一個打印按鈕,它調用window.print(),它只在iFrame中打印某個div。我正在使用媒體查詢來執行此操作。在我print.css我有這2個查詢打印iFrame媒體查詢

@media print { 
    /* 
    * This is the normal print when I want to print the web page, 
    * it hides the menu and other unnecessary information 
    * so that it won't print 
    */ 
} 

@media print and (max-width: 900px) { 
    /* 
    * here I set the body's visible to hidden, 
    * and only display the div that I want to print 
    */ 
} 

的問題是,當我只想定期打印第​​二媒體查詢被應用,因爲第二個媒體查詢隱藏的身體我得到一個空白頁。它在iFrame中正常工作。如果我在哪裏刪除第二個媒體查詢,我可以正常打印,但是當我從iFrame打印時,它會從父窗口打印出所有必需的背景資料。如果我將兩者結合在一起,那麼我將不得不在網頁上爲我想要打印的所有內容添加「特殊」選擇器,否則當我獲得空白頁面時。有任何想法嗎?

回答

0

我剛將max-width更改爲min-width