加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

javascript – JQuery动画边框

发布时间:2020-12-14 22:47:13 所属栏目:资源 来源:网络整理
导读:我有这个HTML代码 它具有这种css风格 #mainNav { display:block; padding:5px; } #mainNav ul { display:block; list-style-type:none; width:500px; border-collapse:collapse; } #mainNav li { display:inline-block; width:100px; height:66px; text-alig

我有这个HTML代码

最佳答案
试试下面,

DEMO

$(document).ready(function() {
    $('#mainNav li').hover(function() {
        var el = $(this);
        $(this).stop(true,true).animate({
            "border-bottom-width": "5px"
        },{
            queue: false,duration: 500
        });
        $(this).children('a').addClass('aHover');
    },function() {
        var el = $(this);
        $(this).stop(true,true).animate({
            "border-bottom-width": "0px"
        },duration: 500
        });
        $(this).children('a').removeClass('aHover');
    });
});

改变,

> mouSEOver事件到mouseenter,因为它更适合你的情况
>将mouseenter / mouseleave更改为悬停
>更改= 5px,– = 5px到5px和0px.
>添加.stop(true,true)以确保动画完成并清除队列.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读