2016-09-28 65 views
0

演示: [http://everythinghomegrown.com/](看定制自己部分与四张蝙蝠侠图片)为什么背景大小上的CSS转换不起作用?

出于某种原因,背景大小的未转换。相反,它会从一种尺寸跳到另一种尺寸,而没有平滑过渡。


div { 
    background-size: 100%; 
    transition: all 0.2s ease; 
} 

div:hover, div:focus { 
    background-size: 115% 115%; 
} 

为什么不工作的过渡?我在Chrome,Safari和Firefox中遇到过这种情况。

+1

请在您的问题中包含最少量的代码,以便我们可以重现问题。不只是一个链接到您的网站。 –

回答

0

已解决。

本来我有这样的:

div { 
    background-size: 100%; 
    transition: all 0.2s ease; 
} 

div:hover, div:focus { 
    background-size: 115% 115%; 
} 

我通过添加第二个值的背景大小属性固定的问题。

div { 
    background-size: 100% 100%; /* added second 100% to fix the problem */ 
    transition: all 0.2s ease; 
} 

div:hover, div:focus { 
    background-size: 115% 115%; 
}