简体   繁体   English

jQuery中链接悬停时文本模糊?

[英]Blurry text on link hover in jQuery?

I would like to create a blurry effect that will last eg 500 ms and then it goes back to normal in some animation that will last eg 250ms. 我想创建一个可以持续例如500毫秒的模糊效果,然后在可以持续例如250毫秒的某些动画中恢复正常。 So, if the user hover over the link it will animate a blurry/fuzzy effect on this link text and then goes back to normal. 因此,如果用户将鼠标悬停在链接上,它将为该链接文本设置模糊/模糊效果的动画,然后恢复正常。

Let's say I have this code: 假设我有以下代码:

<a class="link-to-blurry" href="http://example.com">Text to blurry on hover</a>

Can this be done using jQuery or some additional JavaScript plugin? 可以使用jQuery或其他一些JavaScript插件来完成此操作吗?

You could try something like this: 您可以尝试这样的事情:

CSS: CSS:

a, a:hover {
    color: black;
    font-size: 1.5em;
    text-decoration: none;      
}

.on {
    transition: text-shadow 500ms;
    -webkit-transition: text-shadow 500ms;
    -moz-transition: text-shadow 500ms;
    -ms-transition: text-shadow 500ms;
    -o-transition: text-shadow 500ms;
    text-shadow: 0 0 10px #000;
}

.off {
    transition: text-shadow 250ms;
    -webkit-transition: text-shadow 250ms;
    -moz-transition: text-shadow 250ms;
    -ms-transition: text-shadow 250ms;
    -o-transition: text-shadow 250ms;
    text-shadow: 0;
}

JS: JS:

$('a').hover(function(){
    $(this).removeClass('off').addClass('on');
}, function(){
    $(this).removeClass('on').addClass('off');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM