可放置高度的可滚动容器

时间:2014-06-25 10:34:13

标签: javascript css html5

**scrollable container without putting height## Heading ##**

<div class="container">
<header>
    HOME
</header>
<div class="image-responsive">
  <img src="http://www.colorcombos.com/images/colors/003366.png">
</div>
<div class="container-scroll">
    <p>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
        simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
    </p>
</div>
<footer>x y z</footer>

我已经尝试将div设置为可滚动但没有放置任何固定高度但是它无法正常工作,并且在图像根据设备响应的标题部分之后有一个图像。

我想要一个像这样显示图像的模板,我的图像根据设备响应。  并且中间部分(文本容器)应该可以滚动而没有任何高度。

1 个答案:

答案 0 :(得分:0)

您可以像这样计算(javascript)剩余的可用高度:

var yourScrollableDivsHeight = windowHeight - stickyHeaderHeight - stickyFooterHeight - dynamicImageHeight;

获得此号码后,您可以将其作为可滚动Div的固定高度,并将overflow-y:auto;应用于该号码。