【问题标题】:animate only div instead of whole page when clicking on link in query单击查询中的链接时,仅动画 div 而不是整个页面
【发布时间】:2012-10-13 19:13:37
【问题描述】:

我使用 jQuery、CSS 和 HTML 开发了一个网站。该页面在左侧有一个应该始终显示的静态菜单和一个内容 div。当我现在按下菜单中的链接时,整个页面都会动画并向左滑动,显示菜单元素使用 href 链接到的 div。我非常想修改它,所以只有内容 div 动画并被替换。这可能吗?

问候

【问题讨论】:

  • 请发布一些代码,以便我们知道我们正在使用什么

标签: javascript jquery html css


【解决方案1】:

是的,这是可能的。没有一些代码,我能给你的就不多了。这是我能得到的最通用的:

$(".menuLink").click(function() {
    var linkedContent = ...identify the content being moved into view...
    var currentContent = ...identify the content being moved from view...

    var moveOldTo = "-=" + currentContent.width() + "px";
    //assuming your content divs are relatively positioned
    currentContent.animate({ left: moveOldTo }, 1000);

    var moveNewTo = "-=" + linkedContent.width() + "px";
    linkedContent.animate({ left: moveNewTo }, 1000);
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-18
    • 2013-09-18
    • 1970-01-01
    • 2016-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多