【发布时间】:2017-12-26 05:10:08
【问题描述】:
我已经看过few 示例,但似乎仍然无法弄清楚这个...有没有办法用 div 填充页面的其余部分 使用 Angular 材质而不使用计算?
通过使用“calc()”确定剩余高度,我已经能够让底部 div 很好地填充页面的其余部分,但现在第一列的高度可能会发生变化(400px、200px、0px ) 所以我需要找到一种方法来做到这一点,而不必使用 calc。
My page 设置基本上是:导航栏(固定高度),第一列(高度可能发生变化),第二列(应该填满页面的其余部分 - 虽然内容长度可能会发生变化,所以应该只有内容的滚动条内容(不包括标题)而不是整个 div)。
HTML:
<div layout="column" layout-fill>
<md-toolbar>
toolbar
</md-toolbar>
<div class="main">
<div style="height:100%" layout-fill>
<div flex layout="column" class="firstColumn">
<div class="header1">
first column header 1
</div>
<div class="header2">
first column header 2
</div>
<div>
first column content
</div>
</div>
<div flex layout="column" class="secondColumn">
<div class="header3">
second column header 1
</div>
<div class="header4">
second column header 2
</div>
<div>
second column content:
could be really really long, or really really short...
needs a scrollbar if long, and for the background to still fill the page if not long.
</div>
</div>
</div>
</div>
</div>
CSS:
.main {
height: calc(100%-64px);
}
.md-toolbar {
background-color: black;
height: 64px;
}
.firstColumn {
height: 200px;
background-color:green;
}
.secondColumn {
background-color:red;
}
.header1, .header3 {
height: 64px;
}
.header2, .header4 {
height: 28px;
}
沃金代码:JSFiddle
【问题讨论】:
标签: javascript html css angularjs angular-material