jQuery:在元素hides()时防止div崩溃 [英] JQuery: Prevent div from collapsing when element hides()

查看:69
本文介绍了jQuery:在元素hides()时防止div崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提交表单后,表单滑出"并使用$.get()加载另一个页面并将其滑入.在隐藏表单和显示下一页之间,div折叠并且所有我的页脚内容短暂地停留在表单所在的位置.

When my form is submitted, the form "slides out" and using $.get(), I load another page and slide that in. In between the hiding of the form and the showing of the next page, the div collapses and all my footer stuff briefly ends up where the form was.

然后,当下一页"完成加载时,页脚回到底部(在新页面内容下方). 因为表格的大小可以相差很大,所以我试图避免为DIV指定高度.

Then, when the "next page" finishes loading, the footer goes back to the bottom (under the new page content). because the size of the form can vary a lot, i'm trying to avoid specifying a height for the DIV.

有什么办法可以使div保持不变?

Is there any way to keep the div from changing?

代码:

$("#MyForm").hide("slide", { direction: "left" }, 250, function () {
    $.get("../NewPage.html", function (data) {
        $("#NewPagePlaceholder").html(data);
        $("#NewPagePlaceholder").show("slide", { direction: "right" }, 250);
    });
});

推荐答案

上面的其他选项可能更好,您可以选择基于子div来设置hieght,但是很难知道这是否是一个好方法.想法,看不到任何代码.

The other options above are likely better, you do have the option of setting the hieght based on the child div but it is hard to know if this is a good idea without seeing any code.

例如(未试用):

var height = $('#childdiv').height();
$('#childdiv').parent().css('height', height);

这篇关于jQuery:在元素hides()时防止div崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆