jquery - 使用 JQuery 从中心动画增长

标签 jquery animation

我正在寻找一个来自按钮的弹出 div。单击按钮时,我希望弹出窗口从按钮中心向外生长,同时滑动到屏幕中心。我认为这应该不会太难,但我在任何地方都找不到任何片段。任何帮助将不胜感激。

感谢 Jamie Dixon 的帮助,我让这段代码正常工作。

$('#grower').css({
    backgroundColor: '#FFFFFF',
    border: '10px solid #999',
    height: '0px',
    width: '0px',
    color: '#111111',
    fontWeight: 'bold',
    padding: '10px',
    display: 'none',
    position: 'absolute',
    left: $(this).position().left,
    top: $(this).position().top
}).appendTo('#overlay').fadeIn(0).animate({
    position: 'absolute',
    height: '200px',
    width: '600px',
    marginTop: '-120px',
    marginLeft: '-320px',
    display: "",
    top: ((($(parent).height() - $(this).outerHeight()) / 2) + $(parent).scrollTop() + "px"),
    left: ((($(parent).width() - $(this).outerWidth()) / 2) + $(parent).scrollLeft() + "px")
}, 1000);

最佳答案

您可以通过将“scale”作为参数传递给 show 方法来使用 jQuery UI。

 $('#growwer').show("scale",{}, 1000);

Working example

为了将元素滑动到页面中心,我创建了 Tony L 的 jQuery 函数的修改版本,可在此处找到:Using jQuery to center a DIV on the screen .

Working Example

更新

这是同时运行两个动画的工作示例:

http://jsfiddle.net/wNXLY/1/

为了使其正常工作,我在传入的 animate 函数中包含了一个额外的参数:{duration:urationLength,queue: false}

关于jquery - 使用 JQuery 从中心动画增长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10351431/

相关文章:

javascript - 从 JavaScript 使用参数调用 PHP 脚本

javascript - 将 jQuery 验证与 Bootbox 结合使用

android - 自定义进度条更新不流畅

swift - 缩放和移动 UIView 的动画(快速)

jquery - 将鼠标悬停在子菜单上后保持父菜单项突出显示(HTML/CSS/Jquery)

javascript - jquery 单击单选按钮和边框 TD

ios - 是否可以为 UIEdgeInsets 设置动画?

animation - Snap SVG - 对路径元素进行动画处理

jquery - 使用 jQuery 在 DataTables 中进行复选框排序

javascript - 哪种解决方案性能最佳