【问题标题】:multiple segments with variable heights CSS具有可变高度CSS的多个段
【发布时间】:2015-02-17 10:47:43
【问题描述】:
+---------------------------+
+ row 1: fixed height 40px  +
+---------------------------+
+ row 2: fixed height 40px  +
+---------------------------+
+                           +
+ row 3: variable height    +
+ display all user content  +
+                           +
+---------------------------+
+                           +
+ row 4: variable height,   +
+ whatever space is left.   +
+ Table scroll              +
+                           +
+---------------------------+
+ row 5: fixed height 40px  +
+---------------------------+

有人可以帮我解决这个问题吗?两排可变高度让我失望。另外,据我了解,使用表格滚动条,我需要告诉它所需的高度。但是,如果这是根据第 3 行计算的,我该怎么做?我一直在玩这样的东西(行是引导网格):

CSS:

div.row1, div.row2, div.row5 {
    height: 40px;
}
div.row3 {
    /* No styling so the height can grow as needed */
}
div.row4, div.table-scroll {
    /* How do I set the height here? */
    overflow:auto;

}

HTML:

<div class="row row1">
    some content here
</div>
<div class="row row2">
    some content here
</div>
<div class="row row3">
    <div ng-repeat="blah"> Hello </div>
</div>
<div class="row row4">
    <div class="table-scroll">
        <table>
            <tr ng-repeat="blah">
                <td>text</td>
            </tr>
        </table>
    </div>
</div>
<div class="row row5">
    :w
</div>

row1-height、row2-height、row3-height、row4-height、row5-height之和应该是100%

【问题讨论】:

  • 各种高度之和应该等于...什么?
  • 已更新。第 1 行、第 2 行、第 3 行、第 4 行、第 5 行的高度之和应为 100%

标签: css twitter-bootstrap


【解决方案1】:

这在今天是不可能的: Make a div fill the height of the remaining screen space

您将不得不使用 javascript 来计算侧面,请参阅链接中的第一个答案。

如果您不介意设置大小,那么这里有一个固定高度的小提琴:Fiddle

我将宽度设置为:

#rowlarge {
    height: 70%;
}
#rowsmall {
    height: 30%;
}

【讨论】:

  • 请在投票前发表评论
猜你喜欢
  • 2017-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-24
  • 2011-06-01
  • 2017-02-13
  • 2019-03-24
  • 1970-01-01
相关资源
最近更新 更多