【发布时间】:2019-05-29 21:06:48
【问题描述】:
我有很多父容器。一个页面上有很多这样的例子。 它们有不同的高度。
这是 DIV 的层次结构:
.parent_container
|-----> .title
|-----> .content
.parent_container 有一个固定高度,.title 占据了一些高度
我希望.content 占据其余的高度,但不被.title 占据。
我该怎么做呢?
目前我有这个,但由于父容器的高度不同,90% 并不总是很好,因为.title 总是由H2 样式指定的某个高度。
在 CSS 中有没有办法说“内容height = parent_height - 标题高度”?
/*just an example...different parent_containers have diff heights)*/
.parent_container{
height:530px;
}
.content {
height:90%; /* to make room for title */
overflow:auto; /*show scrollbars*/
}
【问题讨论】:
标签: css