动态加载内容时增加 div 的高度(其高度为 100%)
我有一个 div(InnerDiv),其中包含一个启用分页的网格...
经过一些用户操作后,该网格内的数据将加载,我们将拥有一个大网格!
问题是当网格的数据加载时,溢出 div 的底部部分(InnerDiv)并且其中一些数据显示在 div 之外。
我的 body 和 html 的 css 如下所示:
html, body
{
margin: 0; /* get rid of default spacing on the edges */
padding: 0; /* get rid of default spacing on the edges */
border: 0; /* get rid of that 2px window border in Internet Explorer 6 */
height: 100%; /* fill the height of the browser */
border:3px solid red;
}
页面加载时我需要 100% 的 body 高度...
OuterDiv 位于 body 内,如下所示:
div#OuterDiv
{
position:absolute;
width: 100%;
height: 100%;
/*height: auto;*/
margin: 0px;
padding: 0px;
top: 0;
bottom: 0;
left: 0;
right: 0;
border:5px solid green;
}
InnerDiv Inside OuterDiv 如下所示:
div#InnerDiv
{
position: relative;
width: 100px;
height: 100%;
margin: 0 auto;
background: transparent url('../Images/Blue.png') repeat scroll left top;
}
InnerDiv 内的内容如下所示:
#Content
{
position: relative;
top: 10px;
background: transparent url('../Images/Red.png') repeat scroll left top;
width: 550px;
height: 1080px; /*>>>>>>>>>>>>>>>>>>> plz see this line*/
top: 10px;
right: 10px;
padding: 7px;
border: 10px ridge #ce004e;
color: black;
}
网格(内容)位于 InnerDiv 内。 ..
编辑1
下面的例子可以显示我的情况:
这是 jsFiddle 的示例
我们无法通过执行 height:auto 删除 OuterDiv 的position:absolute或 height:100% 在页面开始时不起作用 ->由于 InnerDiv 背景,outerDiv 应该为 100%,并且记住 InnerDiv 高度在开始时不是 1080px ->页面加载时它只有 200px,并且动态地会更改为 1080px!
我想强制黄色区域(InnerDiv)填充整个紫色区域...
另外 InnerDiv 应该有 100% 高度,因为它是页面开始时的背景...
我知道这个问题大约是 100% 高度/但我该如何解决这个问题?
编辑2:
最后这是我的网站:
我的网站
请使用 firebug 更改红色区域的高度 - 因此通过将其更改为 1080px 主体,OuterDiv 和 InnerDiv 将会增长。
但在页面加载时我想要 body 和 OuterDiv 和 InnerDiv 100% 高度。
我怎样才能做到这一点?
提前致谢
I have a div(InnerDiv) which contains a grid with paging enabled...
After some user actions , data inside that grid will load and we will have a big grid!
The problem is when grid's data loads , overflow the div's bottom portion(InnerDiv) and some of those data get's displayed out of the div.
my css of body and html like below :
html, body
{
margin: 0; /* get rid of default spacing on the edges */
padding: 0; /* get rid of default spacing on the edges */
border: 0; /* get rid of that 2px window border in Internet Explorer 6 */
height: 100%; /* fill the height of the browser */
border:3px solid red;
}
i need 100% height of body when page loads...
OuterDiv inside body like below :
div#OuterDiv
{
position:absolute;
width: 100%;
height: 100%;
/*height: auto;*/
margin: 0px;
padding: 0px;
top: 0;
bottom: 0;
left: 0;
right: 0;
border:5px solid green;
}
InnerDiv Inside OuterDiv Is Like Below :
div#InnerDiv
{
position: relative;
width: 100px;
height: 100%;
margin: 0 auto;
background: transparent url('../Images/Blue.png') repeat scroll left top;
}
Content Inside InnerDiv Like Below :
#Content
{
position: relative;
top: 10px;
background: transparent url('../Images/Red.png') repeat scroll left top;
width: 550px;
height: 1080px; /*>>>>>>>>>>>>>>>>>>> plz see this line*/
top: 10px;
right: 10px;
padding: 7px;
border: 10px ridge #ce004e;
color: black;
}
that grid(Content) is inside InnerDiv...
EDIT 1
the below example can show my situation :
Here's an example at jsFiddle
we can not remove position:absolute of OuterDiv , by doing that height:auto or height:100% on it does not work at page start -> outerDiv should be 100% because Of InnerDiv Background and remember InnerDiv height is not 1080px at start -> it is only 200px at page load and dynamically it will change to 1080px!
i want to force yellow area (InnerDiv) to fill entire Purple Area...
also InnerDiv Should Have 100% Height Because Of It's Background At Page Start...
i know this problem is about 100% height / but how can i fix that ?
EDIT 2 :
AT LAST HERE IS MY WEB SITE :
MY WEB SITE
plz change the height of red area with firebug - so by changing it to 1080px body and OuterDiv And InnerDiv Will grow.
but at page load i want body and OuterDiv And InnerDiv 100% height.
how can i do that?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要减少对
#OuterDiv
的限制。通过指定顶部、底部、左侧和右侧,您可以将 #OuterDiv 的边缘锁定到body
的边缘;并且您的主体规则将主体锁定为与视口相同的大小。尝试更改您的
div#OuterDiv
规则,如下所示:这是 jsFiddle 的示例
You need less constraints on
#OuterDiv
. By specifying top, bottom, left, and right, you're locking the edges of #OuterDiv to the edges ofbody
; and your body rule locks body to the same size as the viewport.Try changing your
div#OuterDiv
rule like this:Here's an example at jsFiddle
从我从你的解释和风格中收集到的信息,你基本上想要这个:
http://jsfiddle.net/sg3s/zXSXx /
如果这是正确的,我还将解释每个 div 发生了什么。否则请告诉我哪些 div 的行为不符合您的意愿以及原因。
顺便说一句,如果可能的话,使用图像的绝对路径(整个链接)。了解它们需要如何组合在一起将有助于我们所有人找到适合您的东西。
From what I could gather from your explanation and styles you basically want this:
http://jsfiddle.net/sg3s/zXSXx/
If this is correct I will also explain what is happening to each div. Else please tell me what div is behaving not as you would like and why.
By the way if possible use absolute paths (whole links) to images. Seeing how they need to fit together will help us all to find something that works for you.