使用jQuery对悬停中的特定角进行动画处理 [英] Animating specific corners on hover with jQuery

查看:55
本文介绍了使用jQuery对悬停中的特定角进行动画处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了一个很好的例子

I've found a great example right here discussing how to animate specific corners of a border. However, it seems i get no change what so ever. After inserting an alert into the in and out functions i confirmed that they are fired. However, any change to the cornerization are just not there.

这与我设置div的样式有关吗?

Has it to do with how i styled the divs?

div.menuItem {
    border-width: 5px 3px;
    border-style: solid;
    border-radius: 25px 45px 25px 45px;
    font: 30px Arial;
    font-weight: bold;
    padding: 15px;
    display: block;
    width: 200px;
    border-color: #00bb00;
    color: #fff;
    background-color:#8822cc;
    -webkit-text-stroke: 1px #000;
}

这是脚本.

$('div.menuItem').hover(function () {
            alert("in");
    $(this).animate({
        "MozBorderRadiusTopleft": '50px',
        "MozBorderRadiusTopright": '50px'
    }, 900);
}, function () {
            alert("out");
    $(this).animate({
        "MozBorderRadiusTopleft": '25px',
        "MozBorderRadiusTopright": '25px'
    }, 900);
});

推荐答案

您可以简单地使用 CSS过渡:

div.menuItem {
    border-radius: 25px 45px 25px 45px;
    transition: border-radius .9s;
    /* all other properties... */
}
div.menuItem:hover {
    border-radius: 25px;
}

这是小提琴: http://jsfiddle.net/ucVPg/

PS .请不要忘记供应商前缀.

P.S. Don't forget the vendor prefixes.

这篇关于使用jQuery对悬停中的特定角进行动画处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆