2015-02-07 67 views
3

在我的頁面中,我有一個左側邊欄和一個容器,容器有一個餘量,因爲側邊欄是絕對定位的。@media print不覆蓋主風格

現在打印我隱藏邊欄並恢復容器的左邊緣,但邊緣不會恢復。

這些是我的容器和工具條的樣式:

#sidebar { 
    position: absolute; 
    top: 0; 
    bottom: 0; 
    width: 200px; 
} 
#container { 
    margin-left: 200px; 
    padding: 20px; 
    transition: margin-left .5s; 
} 

@media print { 
    #sidebar { display: none;} 
    #container { 
     margin-left: 0px !important; 
     padding: 0px !important; 
    } 
} 

我使用Chrome 40

回答

5

奇怪的是,這個問題可以在Chrome由print媒體內取出過渡解決查詢:

Example Here

@media print { 
    #sidebar { display: none;} 
    #container { 
     margin-left: 0px !important; 
     padding: 0px !important; 
     transition: none; 
    } 
} 

不刪除轉換,您可以reproduce the issue here。也許這是一個渲染錯誤?

+0

所以很有幫助!爲我工作 – 2015-08-16 07:46:50