在此页面 bonusnavigator.ru
我有一个 div:.toppanel
.topcasino
.inner
它现在显示 11 个分割 - .toppanel
.topcasino
.inner
.row
-(交易)。当我尝试减少交易数量时,我得到了这个:
http://screencast.com/t/eajlX3xNTm2
我如何设置 css 以便子 div 像这样填充释放的空间:
http://screencast.com/t/vKlPct3Avb4V
提前谢谢大家。
更新:感谢前两个建议,但它们处理的是“发布结果”。我想问的是如何设置子 div(交易)以根据父 div 中的交易数量动态更改高度以填充可用空间。
最佳答案
我没有玩过你的 CSS,但你在使用 jquery 吗?如果是这样,您可以使用 height() 函数根据交易数量设置高度。
您可以使用 $(".inner").height(); 获取容器 div 的高度;
然后将高度除以其中的 DIV 数,并将所有子 Div 的高度设置为该值。像这样(语法可能不正确,因为我只是在这里输入代码):
var containerHeight = $(".inner").height();
var divCount = $(".inner > div").length; /* returns the number of DIVs which are direct children of the parent */
var divHeight = Math.Round(containerHeight/divCount); /* number being the count of your divs */
$(".inner > div").height(divHeight);
关于css - 如何根据父div中子div的数量设置div的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20787427/