【问题标题】:animate() not working for the object taganimate() 不适用于对象标签
【发布时间】:2014-07-11 17:16:13
【问题描述】:

我在对象标签中有一个 SVG,我想使用 jQuery 的 animate() 对其进行动画处理,但我似乎无法让它工作。我正在尝试将图像位置更改 20%。我已经在其他标签(例如 IMG 或 DIV)上尝试了确切的动画,并且效果很好。我不想使用 css() 来做到这一点。有什么建议吗?

HTML

<object class="animation" id="picture" data="images/toy.svg"></object>

CSS

.animation {
 display: block;
 position: absolute;
 top: 5%;
 left: 5%;
 width: 30%;
 height: 30%;
 opacity: 1;
}

JavaScript

$(initPage);
function initPage(){
    $("#picture").animate({"top":"20%"}, "slow");
}

【问题讨论】:

  • 您是否尝试过将其包装在 div 中并为其设置动画?

标签: javascript jquery html


【解决方案1】:

将对象添加到 div 并为 div 设置动画。

HTML

<div class="animation" id="picture">
    <object data="http://t3.gstatic.com/images?q=tbn:ANd9GcRK-yM30mBX0HBwS0htU0MejWfxwabj4X3LhbG-sp8_JzsaxFnt"></object>
</div>

Demo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-17
    • 2014-09-01
    • 2015-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-12
    相关资源
    最近更新 更多