【问题标题】:jquery detach and load need to fade In and Outjquery detach 和 load 需要淡入淡出
【发布时间】:2012-03-15 10:29:18
【问题描述】:

我正在尝试使此功能更好地工作,但我无法找到解决方案。

我想让页面相互淡入淡出。 有什么建议吗?

        $('.edit-account').click(function(){

            $('#section-wrapper').detach();

            $('#inline-cont').load('../my-profile/edit-profile.html #inline_content');

            $('#inner-wrap').load('../my-profile/edit-profile.html #section-wrapper', function(){
                $('#close-account').click(function() {
                        $('#section-wrapper').detach();
                        $('#inline-cont').load('../my-profile/close-account.html #inline_content');
                        $('#inner-wrap').load('../my-profile/close-account.html #section-wrapper');
                });
            });
        });

【问题讨论】:

    标签: jquery fading detach


    【解决方案1】:

    这里有几个选项,如果没有更多上下文/CSS/HTML,很难说出最适合您的解决方案。

    1. 使用 jQuery 制作动画(假设您最初将 CSS 属性 opacity 设置为 0)

      $('#yourSelector').animate({opacity: 1}, 1000, function() {// 动画完成。});

    更多关于 .animate 的信息在这里:http://api.jquery.com/animate/

    1. 使用 CSS 过渡(IE http://caniuse.com/#search=transition 不支持) 如果您最初将 opacity 设置为 0,那么只需将元素的 CSS opacity 属性更改为 1 $('#yourSelector').css('opacity':'1'); 在它加载到 DOM 中之后,CSS 转换将处理其余部分。

      .yourSelector { -webkit-transition:不透明度 .2s 缓入 0s; -moz-transition:不透明度 .2s 缓入 0s; -o-transition:不透明度 .2s 缓入 0s; -ms-transition:opacity .2s 缓入 0s; 过渡:不透明度 .2s 缓入 0s; }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-22
      • 2023-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多