分配“休息”高度到div? [英] Allocate "rest" of height to a div?
问题描述
我有这个:
< div style =" width:100%; height:20px">
bla
< / div>
< div style =" width:100%; height:???; overflow:scroll">
something
非常
身高
所以
它
生产
a
滚动条
< / div>
< div style =" width :100%;身高:50px">
另外的东西
< / div>
三个问号表示我想把它放在那里我想要说的是窗口高度减去20px减去50px,但我不知道
怎么说。
我目前的解决方法是在< / body>之前添加一些JavaScript其中
计算窗口的高度(以像素为单位),从这个
数字中减去75(75 = 20 + 50 +软糖因子),然后来自
文件说width:4711px而不是width:???。
此解决方法的问题在于,当用户使用相应的div时不会重新调整大小调整窗口大小:当用户调整窗口大小时,div正确缩小
或更宽,中间的那个
不会更高或更低 - 更少,更少高大? - 在调整大小期间。
一时兴起,我也尝试过宽度:90%。但是这导致了比高高的东西更高的div b / b
。在它里面。
我希望我说清楚我想要什么。火焰消失,如果我没有。
建议?
启
I have this:
<div style="width:100%;height:20px">
bla
</div>
<div style="width:100%;height:???;overflow:scroll">
something
very
tall
so
that
it
produces
a
scrollbar
</div>
<div style="width:100%;height:50px">
another stuff
</div>
The three question marks indicate what I want to put there. What I
want to say is "window height minus 20px minus 50px", but I don''t know
how to say it.
My current workaround is to put some JavaScript before </body> which
calculates the height of the window in pixels, subtracts 75 from this
number (75 = 20 + 50 + fudge factor), then frobs the DOM of the
document to say "width:4711px" instead of "width:???".
The problem with this workaround is that the corresponding div doesn''t
resize when the user resizes the window: while the divs get narrower
or wider properly when the user resizes the window, the middle one
doesn''t get taller or --err, less tall?-- during the resizing.
On a whim, I also tried "width:90%" but that resulted in the div
growing as tall as the "something tall" inside it.
I hope I made it clear what I want. Flame away, if I didn''t.
Suggestions?
Kai
推荐答案
Kai Grossjohann写道:
Kai Grossjohann wrote:
我有这个:
< div style =" width:100%; height:20px">
bla
< / div>
< div style =" width:100%; height:???; overflow:scroll">
某事
非常
它产生
一个滚动条
< / div>
< div style =" width:100%; height:50px">
其他东西
< / div>
三个问号表示我想要放在那里。我想说的是窗户高度减去20px减去50px,但我不知道怎么说。
唯一的方法是JavaScript AFAIK
我目前的解决方法是在< / body>之前添加一些JavaScript
以像素为单位计算窗口的高度,从此
数字中减去75(75 = 20 + 50 +软糖因子),然后将
文档的DOM称为宽度 :4711px"而不是width:???。
你的意思是身高:???;,对吧?
这个解决方法的问题是相应的div没有调整大小当用户调整窗口大小时:当用户调整窗口大小时,div会变得更窄或者更宽,中间的那个没有更高或更低,更高? - 期间调整大小。
I have this:
<div style="width:100%;height:20px">
bla
</div>
<div style="width:100%;height:???;overflow:scroll">
something
very
tall
so
that
it
produces
a
scrollbar
</div>
<div style="width:100%;height:50px">
another stuff
</div>
The three question marks indicate what I want to put there. What I
want to say is "window height minus 20px minus 50px", but I don''t know
how to say it.
Only way is JavaScript AFAIK
My current workaround is to put some JavaScript before </body> which
calculates the height of the window in pixels, subtracts 75 from this
number (75 = 20 + 50 + fudge factor), then frobs the DOM of the
document to say "width:4711px" instead of "width:???".
You mean height:???;, right?
The problem with this workaround is that the corresponding div doesn''t
resize when the user resizes the window: while the divs get narrower
or wider properly when the user resizes the window, the middle one
doesn''t get taller or --err, less tall?-- during the resizing.
可以使用JS(调整大小部分)检测。
-
Anne van Kesteren
< http://www.annevankesteren.nl/>
That is possible to detect using JS (the resizing part).
--
Anne van Kesteren
<http://www.annevankesteren.nl/>
你难道不能修复底部div视口的底部,所以你不要
必须指定中间的高度?
2003年11月12日星期三19:15: 18 +0100,Anne van Kesteren写道:
Can''t you fix the bottom div to the bottom of the viewport so you don''t
have to specify a height on the middle?
On Wed, 12 Nov 2003 19:15:18 +0100, Anne van Kesteren wrote:
这三个问号表示我想放在那里。我想要说的是窗口高度减去20px减去50px,但我不知道如何说出来。
The three question marks indicate what I want to put there. What I want
to say is "window height minus 20px minus 50px", but I don''t know how to
say it.
只有这样是JavaScript AFAIK
Only way is JavaScript AFAIK
-
..
--
..
>
Vigil< me@privacy.net>写在
新闻:pa **************************** @ privacy.net:
Vigil <me@privacy.net> wrote in
news:pa****************************@privacy.net:
你不能将底部div修复到视口的底部,这样你就不必在中间指定一个高度吗?
Can''t you fix the bottom div to the bottom of the viewport so you
don''t have to specify a height on the middle?
这会导致更多的问题而不是它解决的问题。如果由于某种原因,
视口不够高,无法显示整个页面,那么固定页脚
将粘贴在视口底部,内容将滚动在下面
it。
That causes more problems than it solves. If for whatever reason the
viewport isn''t tall enough to display the entire page, then a fixed footer
will stick at the bottom of the viewport and content will scroll underneath
it.
这篇关于分配“休息”高度到div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!