首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery Load()未形成DIV

jQuery Load()未形成DIV
EN

Stack Overflow用户
提问于 2012-11-28 23:26:27
回答 1查看 298关注 0票数 1

嘿,我在div中使用jQuery的load()函数加载HTML页面时遇到了一些问题。如果我的页面中有比DIV更大(更大的高度)的内容,那么它只会在潜水过程中流血。

在DIV上使用jQuery load()之后,我的页面就是这样的:

加载时应该是这样的:

这就是我的HTML代码的样子:

代码语言:javascript
复制
 <div class="container_1" id="mainHTML">  
  <div class="pageinner" id="innerHTML">
    <p style="font-size: 24px;" class="MMHeader">The CMS System<p>
    <p style="color: #F90;" class="mmBelowHeader">Please provide your email and password below in order to log into the CMS system.<p>
        <section class="main" id="mainContent">
            <div class="form-4">
                <p>
                    <input type="text" name="username" id="username" placeholder="Email Address">
                </p>
                <p>
                    <input type="password" name='password' id="password" placeholder="Password"> 
                </p>

                <p>
                    <button class="orange" name="forgotLoginButton" id="forgotLoginButton" onclick="shrinkBox();" style="margin-right: 5px;">Forgot Password</button>
                    <button class="blue" name="LoginButton" id="LoginButton" onclick="mainMenu();" >Log in</button>
            </div>​
        </section>
  </div>
</div>

<script type="text/javascript">
$(document).ready(function() {
    $("#mainHTML").animate({width:500, height: 300, overflow: 'auto'});
    $("#innerHTML").animate({width:470, overflow: 'auto'});
    $(".form-4").animate({margin: '10px auto 10px', overflow: 'auto'});
    $('#mainContent').load('test.html');
});
</script>

我确定这是因为我是动画的宽度/高度的盒子,但有一种方法,以保持加载的内容在DIV和大小的高度,根据什么加载?

更新

代码语言:javascript
复制
$('#mainContent').fadeOut(0).load('test.html', function() {
    $('#mainHTML').animate({width:940, height: 'auto'});
    $("#innerHTML").animate({width:940, overflow: 'auto'});
}).fadeIn(2000);

但是不是将div调整为加载的html内容高度吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-28 23:50:39

检索数据后,尝试重置#mainHTML的高度:

代码语言:javascript
复制
$('#mainContent').load('test.html', function() {
  $("#mainHTML").stop().css({height: 'auto'});
})

http://jsfiddle.net/KzEpL/

http://jsfiddle.net/KzEpL/1/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13616256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档