CSS / DIV问题

时间:2010-09-21 22:44:04

标签: css html

我有一个标题,我想要坚持到顶部和一个我想要坚持到底部的页脚,以及一个我想尽可能多地占据中间的银色控件,而不会溢出到页脚上(或头)。它主要适用于我:

div#silverlightControlHost 
{
  float:left;
  height: 80%;
  width: 100%;
}

div#footer
{
  position: absolute; 
  bottom: 0px;
  width: 100%;
  left: 0px;
}

我唯一的问题是当分辨率较低时,例如1024x768,在这种情况下,页脚部分被silverlight控件覆盖。有关如何指定silverlight控件相对于页眉和页脚的高度的任何建议?实际上,“身高:< 100%> - HeaderHeight - FooterHeight&gt ;;”

2 个答案:

答案 0 :(得分:1)

一种可能性,如果你确切知道页眉和页脚的高度,就是使用top :(标题的高度)px;底部:(页脚高度)px;高度:汽车;

答案 1 :(得分:0)

使用纯CSS无法做到这一点。使用JavaScript,在屏幕调整大小时更新:

window.onresize = function ()
{
    var silverlight,headerHeight,footerHeight,windowHeight;

    if (typeof(window.innerHeight) != 'undefined')
        windowHeight = window.innerHeight;
    else
        windowHeight = document.body.offsetHeight;

    silverlight = document.getElementById('silverlightControlHost');
    headerHeight= parseInt(document.getElementById('header').style.height,10);
    footerHeight= parseInt(document.getElementById('footer').style.height,10);
    silverlight.style.height = (windowHeight - headerHeight - footerHeight) + "px";
}