代码之家  ›  专栏  ›  技术社区  ›  da5id

处理多个滚动列的最佳方法

css
  •  6
  • da5id  · 技术社区  · 18 年前

    我正在开发一个web应用程序,该应用程序在视觉上由一个标题和一个包含四列可变高度内容的正文组成。设计之神已经将其定为固定高度,主要是因为每一列都可能变得很长,因此(作为设计师)他们想要有独立滚动条的iFrame。

    蒂亚。

    编辑:我不是在寻找CSS布局解决方案本身,我的问题是如何在不固定主体高度(以像素为单位)的情况下,满足主体容器中每个列的最大高度和可滚动的需要,除非我绝对需要。

    4 回复  |  直到 18 年前
        1
  •  9
  •   Stringent Software    18 年前

    我很确定这正是你所需要的: Liquid 4 column layout with fixed height banner and footer

    没有iFrame,没有java脚本,每列都会自动填充可用高度。

        2
  •  0
  •   Dimitry    18 年前

    你在说这样的事吗?

    <div id="head"></div>
    <div id="body">
      <div id="col1"></div>
      <div id="col2"></div>
      <div id="col3"></div>
      <div id="col4"></div>
    </div>
    

    #body { position: absolute; top: 60px /* height of the header */; bottom: 0px; width: 100%;  }
    #body div { position: absolute; top:0; bottom:0 ;width: 25% }
    

    window.onResize = function () {
        // Calculate the height of the body, substract the height of the head and apply to all columns
    }
    
        3
  •  0
  •   Eric Wendelin    18 年前

    在回答第二个问题时,只需在CSS中设置height属性,以确保内容永远不会超过所需的大小。你 可以 使用overflow-y:scroll(不是有效的CSS,但有效)在元素上强制使用滚动条。

        4
  •  0
  •   pdc    18 年前

    我试过各种不同的排列方式 DIV 元素相互嵌套,一个设置为 height:100% 另一个呢 padding:60px height

    我必须说,我希望CSS允许人们将高度表示为百分比、字体相对和像素单位的和(或差)(如

    width: 12em - 2px;
    border: 1px solid #FED; /* Total width including border is 12em exactly */
    

    width: 25% - 1em;
    margin: 1.25em 1em;
    

    以此类推,比如TeX及其fil单元)。

    我认为最好的选择可能是使用一些JavaScript来检查横幅的高度,并从视口的高度中减去横幅,然后适当地设置包含列的框的高度。然后,您将了解designer blokes使用的屏幕大小,并在CSS文件中设置硬连线默认值以适合其显示。