2016-10-31 49 views
1

我有一個基本的設置,以放大它的容器中的超大圖像。除了當您嘗試打印Chrome時(除FF和IE之外的打印按預期工作),它完美的工作。相反,Chrome的打印預覽不會調整圖像的大小。鉻打印CSS圖像不調整大小

惱人的是我無法重現這個問題,所以我希望有人能夠提出一些可能的建議嗎?

這是基本設置: https://jsfiddle.net/aed2gh3w/

<style> 
.container { 
    position:relative; 
    width:20%; 
    padding-bottom:20%; 
    border:1px solid red; 
    margin:0 auto; 

} 

.align { 
    position:absolute; 
    left:50%; 
    margin:0 -400px; 
    top:0; 
    width:800px; 
    height:100%; 
    border:none; 
    text-align:center; 
} 

img { 
    vertical-align:top; 
    height:100%; 
    width:auto; 
} 

</style> 
<div class="container"> 
    <div class="align"> 
    <img src="http://placehold.it/400x300"> 
    </div> 
</div> 
+0

它工作正常,我 – paolobasso

+0

@ paolo.basso99我無法複製超出了我完整的代碼的問題,所以我要尋找的建議,什麼可能導致它? – user500665

+0

這個解決方案可能適合你嗎? http://stackoverflow.com/questions/25396682/window-with-image-print-issue-in-chrome – natel

回答

0

原來,問題是因爲我沒有一個高度爲.container 即使沒有高度設置,因爲它的所有填充,我還是需要將height:0;添加到它的風格,否則Chrome會在一半時間內感到困惑。