0

如果你看到这个网站

当您将鼠标悬停在子无序列表上时,底部边框不会正确对齐。只有在 14-19 才会发生这种情况。

这是代码:

(function($) {
$.fn.lavaLamp = function(o) {
    o = $.extend({ fx: "linear", speed: 500, click: function(){} }, o || {});
    return this.each(function() {
        var me = $(this), noop = function(){},
            $back = $('<li class="back"><div class="left"></div></li>').appendTo(me),
            $li = $("li", this), 
            curr = $("li.active", this)[0] || $($li[0]).addClass("active")[0];

        $li.not(".back").hover(function() {
            move(this);
        }, noop);

        $(this).hover(noop, function() {
            move(curr);
        });

        $li.click(function(e) {
            setCurr(this);
            return o.click.apply(this, [e, this]);
        });

       setCurr(curr);

        function setCurr(el) {
            $back.css({ "left": el.offsetLeft+"px", "width": el.offsetWidth+"px", "border-bottom-color": $(el).css("border-bottom-color") });
            curr = el;
        };
        function move(el) {
            $back.each(function() {
                $(this).dequeue(); }
            ).animate({
                width: el.offsetWidth,
                left: el.offsetLeft
            }, o.speed, o.fx).css({"border-bottom-color": $(el).css("border-bottom-color")});
        };
    });
};
})(jQuery);

有人可以解释一下这里发生了什么以及我如何修改上述内容。

谢谢

4

1 回答 1

1

你可以试试这个:

function move(el) {
  $el=$(el);
  $back.each(function() {
    $(this).dequeue(); 
 }).animate({
   width: $el.width(),
   left: $el.offset().left
   }, o.speed, o.fx).css({"border-bottom-color": $el.css("border-bottom-color")});
}; 
于 2013-04-17T14:53:59.980 回答