Why is transform:scale not kept on :hover?

。_饼干妹妹 提交于 2019-12-07 16:36:06

问题


I am using this CSS:

.link {
    transition: all .2s ease-in-out;
}
.link:hover {
    transform: scale(1.1);
}

When I hover the text, it's scaled to 110% as expected, but as soon as the transition is finished, it scales back to 100% even though the mouse pointer is still on the text.

When I remove the mouse pointer from the text, the animation scales to 110% then back to 100% in a flash.

See this fiddle for a demo.

How can I make it keep the 110% scale until the pointer leaves the text?


回答1:


You need to define a link as display: inline-block, and add prefixes. CSS:

.link {
    display: inline-block;
}

.link:hover {
    -webkit-transform: scale(1.1); /* Chrome, Safari, Opera */
    transform: scale(1.1);
}

FIDDLE




回答2:


Can you use Jquery ?

$(".link").hover(function(){ ... }); 

or maybe

$(".link").mouseover(function(){ ... });


来源:https://stackoverflow.com/questions/30483787/why-is-transformscale-not-kept-on-hover

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!