根据用户监视器的大小/分辨率动态调整div的高度 [英] Dynamically resizing the height of div based upon the size/resolution of user's monitor

查看:104
本文介绍了根据用户监视器的大小/分辨率动态调整div的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个三行,一列的网站设计,我想要中心内容div调整大小适合列的其余部分(屏幕的高度 - (硬编码footerheight +硬编码头高度))。有一个可爱的方式来做这个CSS?

I have a three row, one column site design and I'd like to have the center content div resize to fit the remainder of the column (height of screen - (hardcoded footerheight + hardcoded header height)). Is there a cute way to do this with CSS? If not, how can I accomplish this with javascript?

谢谢,

Tom

#container {
  background-color: gray;
  height: 100%;
}
#centercolumn {
  background-color: white;
  margin-left: auto;
  margin-right: auto;
  width: 800px;
  height: 100%;
}
#header {
  background-color: blue;
  height: 150px;
}
#content {
  background-color: yellow;
}
#footer {
  height: 50px;
  background-color: blue;
}

<html>
  <head>
    <link rel="stylesheet" href="test.css" type="text/css" media="screen"/>
  </head>
  <body>
    <div id="container">
      <div id="centercolumn">
        <div id="header">
          header
        </div>
        <div id="content">
          content
        </div>
        <div id="footer">
          footer
        </div>
      </div>
    </div>
  </body>
</html>


推荐答案

Sticky Footer 将为您免费设置。

这篇关于根据用户监视器的大小/分辨率动态调整div的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆