我正试图实现最近看到的效果,其中背景图像放大悬停。我几乎在这里用例子:https://jsfiddle.net/qyh6nbwt/,但它似乎很不稳定(你会理解我的意思是悬停在它上面),我在osx上运行最新的chrome版本,还没有在其他浏览器中检查它。 有没有办法让它更平滑,所以在放大时不会“摇晃”?悬停时的背景大小过渡导致Chrome“晃动”背景图像
HTML
<div id="example">
test
</div>
CSS
#example {
background-image: url(http://www.jeroenkemperman.nl/wp-content/uploads/2014/06/Johns_Inc_Pizza_Spaghetti_wikipediacommons.jpg);
background-position: center center;
width: 250px;
height: 250px;
transition:all 1000ms ease;
background-size: 100% auto;
}
#example:hover {
background-size: 160% auto;
}
你可以通过在':hover'上添加'transform:scale(1.1)'来修复它,但是这并没有完全解决它。非常感兴趣,看看这是为什么。 –
它是否必须是背景图片? –
嗯,我有肮脏的解决方法,如果你想看到:https://jsfiddle.net/qyh6nbwt/2/ 但它似乎铬性能问题。 –