我的CSS文件相关内容如下:
#centercol
{
   position: relative inherit; margin-left: 200px; padding: 0px;   background-color: white;height: 500px;
}
#footer
{
  position: relative inherit; padding: 0px; margin: 0px; width: 100%; height: 62px;
   background-image: url(images/FooterSlice.gif);
}
现在footer是随着Center的变高而往下移的,但Center中的内容高小于500px时,footer仍然要跟上去,如何控制footer在500px以下的位置显示?

解决方案 »

  1.   

    上面说错了,说的是#centercol 不加height:   500px时的情况。
    加上height:   500px;时,Center内容超过500px时,footer不会上移,会盖在加长了的Center内容上面。
      

  2.   

    height:       5X%;这样看看
      

  3.   

    反复对比了下例程,发现他是把Center的两边填入了500Px的内容
      

  4.   

    对比例程,发现关键是中间的内容影响页脚的位置,找到一种解决方案,建一个div musthight
    #musthight
    {
    position:absolute;margin-left: 200px; padding: 0px;   top: 184px;
    }
    在这个div中,放一个500px高,1px宽,透明的panel控件。页面中还必须有下面的脚本
        <script type="text/javascript">
            function AdjustColumnsHeight()
            {
                // get a reference to the three DIVS that make up the columns
                var centerCol = window.document.getElementById('centercol');
                var leftCol = window.document.getElementById('leftcol');
                var rightCol = window.document.getElementById('rightcol');
                var musthight=window.document.getElementById("musthight");
                // calculate the max height
                var hCenterCol = centerCol.offsetHeight;
                var hLeftCol = leftCol.offsetHeight;
                var hRightCol = rightCol.offsetHeight;
                var hmusthight=musthight.offsetHeight;
                var maxHeight = Math.max(hmusthight,Math.max(hCenterCol, Math.max(hLeftCol, hRightCol)));
                // set the height of all 3 DIVS to the max height
                centerCol.style.height = maxHeight + 'px';
                leftCol.style.height = maxHeight + 'px';
                rightCol.style.height = maxHeight + 'px';       
                hmusthight.style.height=maxHeitht+'px';     
                // Show the footer
                window.document.getElementById('footer').style.visibility = 'inherit';
            }
            window.onload = function() { AdjustColumnsHeight(); }   
        </script>
      

  5.   

    发现还是弄麻烦了,不需要再加DIV的,直接在脚本中改一下就行了