Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 自动高度及;在中间分区滚动-可能吗?_Css - Fatal编程技术网

Css 自动高度及;在中间分区滚动-可能吗?

Css 自动高度及;在中间分区滚动-可能吗?,css,Css,我想: 标题 主要的 页脚,alw。在底部父div 实际(px)容器高度可能会根据客户端窗口大小更改dep, css主题中设置的页脚和页眉高度 所有的定位都应该是相对的。需要JS来解决这个问题吗 (尝试的高度:主屏幕上的自动,似乎没有效果。)您可以使用绝对定位来轻松实现这一点,为什么要将其定位为相对定位 <div style="height:100%"> <div style="height:70px;">header</div> <div

我想:


标题
主要的
页脚,alw。在底部父div
实际(px)容器高度可能会根据客户端窗口大小更改dep, css主题中设置的页脚和页眉高度

所有的定位都应该是相对的。需要JS来解决这个问题吗


(尝试的高度:主屏幕上的自动,似乎没有效果。)

您可以使用
绝对定位来轻松实现这一点,为什么要将其定位为
相对定位

<div style="height:100%">
  <div style="height:70px;">header</div>
  <div style="overflow-y:scroll;">main</div>
  <div style="height:60px;">footer, alw. at bottom parent-div</div>
</div>

jsiddle:

高度:自动
div
的默认行为。是否只希望在达到窗口大小时滚动主div?
#header, #main, #footer {
    left: 0;
    right: 0;
    position: absolute;
}     

#header {
    top: 0;
    height: 70px;
    background-color: yellow;
}

#main {
    top: 70px;
    bottom: 60px;
    background-color: lime;
    overflow: auto;  
}

#footer {
    bottom: 0;
    height: 60px;
    background-color: red;
}