0

在此菜单中,悬停的 div 正在扩展,所有其他元素正在缩小

更改大小时菜单右侧有一个小摆动,这真的很烦人

我已经看到了:使用从中心扩展的 CSS 从中间扩展 div 而不是从顶部和左侧 扩展,他们还提到了摆动

有没有办法解决摆动?

这是我的代码

如您所见,速度始终相同,因此理论上不应该摆动

function add() {
    var speed = 50;
    $('.space').hover(
        function() {
            var n = this.id.replace(/[^\d]/g, '');
            $('#space_' + n).removeClass('contract');
            $('#space_' + n).stop().animate({
                height: "107px",
                width: "107px",
            }, speed, 'linear');
            $('.contract').stop().animate({
                height: "73px",
                width: "70px",
            }, speed, 'linear');
        },
        function() {
            var n = this.id.replace(/[^\d]/g, '');
            $('#space_' + n).addClass('contract');
            if($('#space_' + n).hasClass('selected') != true) {
                $('#space_' + n).stop().animate({
                    height: "73px",
                    width: "73px",
                }, speed, 'linear');
            }
            $('.contract').stop().animate({
                height: "73px",
                width: "73px",
            }, speed, 'linear');
        }
    );
}

add();

在这里您可以看到菜单示例:http: //mellroy.com/dean/

先感谢您

4

1 回答 1

0

摆脱边界 - 而是使用背景图像。如果您将整个菜单放在白色和黑色背景上(与菜单匹配),您将不会看到 wobble - 事件,尽管 wobble 仍然存在。我怀疑你能避免它。

于 2011-12-30T08:37:59.777 回答