1

当使用 animate 更改 html 中的某些内容时,jquery animate '移动'/移动文本而不是仅仅替换文本。

在这里检查:http: //jsfiddle.net/x2VYn/

    function cycleIntro() {
        var whoArr = ["colleagues", "girlfriend", "homies", "nemesis", "lover", "dad", "mom", "brother", "sister", "enemies", "friends", "classmates", "best friend", "imaginary friend", "grandma'"];
        var whatArr = ["pool", "backgammon", "dart", "chess", "ping pong", "bob", "headsup poker", "ludo", "yatzy", "foosball", "tennis", "street basket", "golf", "water polo"];

        var whotxt = whoArr[Math.floor(Math.random() * whoArr.length)];
        while ($("#intro #who").html() == whotxt) {
            whotxt = whoArr[Math.floor(Math.random() * whoArr.length)];
        }
        var whattxt = whatArr[Math.floor(Math.random() * whatArr.length)];
        while ($("#intro #what").html() == whattxt) {
            whattxt = whatArr[Math.floor(Math.random() * whatArr.length)];
        }
        $("#intro #who").animate({ width: "toggle" }, 200, function () {
            $("#intro #who").html(whotxt).animate({ width: "toggle" }, 300, function () {
                $("#intro #what").delay(50).animate({ width: "toggle" }, 200, function () {
                    $("#intro #what").html(whattxt).animate({ width: "toggle" }, 300, function () {
                        setTimeout(cycleIntro, 1500);
                    });
                });
            });
        });
    }
    setTimeout(cycleIntro, 1500);

有谁知道如何调整这个?

4

1 回答 1

1

设置vertical-align您正在操作的跨度的属性以bottom解决问题。我在这里更新了小提琴。

于 2013-11-01T00:56:26.133 回答