如何使页面的div高度长度

Psy*_*lex 2 html css jquery

我试图得到一个内容div来基本上在我的标题和我的脚之间运行页面的整个高度.如果我使用:

  #content{ height: 100%; } 
Run Code Online (Sandbox Code Playgroud)

它只会与div中的内容一样高.有时我可能只有一个句子但是想要div(带背景或边框)来运行屏幕的长度,直到只有75px高大的页脚.

有没有办法用CSS轻松做到这一点?目前我所拥有的是:

  <style>
  #content {
  margin-top: 0px;
  height: 800px;
  width: 800px;
   margin-left: auto;
   margin-right: auto;
    background-color: #E0E0E0 ;
   }
  </style>
   </head>
  <body>
  <div id="content"> 
  this is a div!  with some centered crap
  </div>
Run Code Online (Sandbox Code Playgroud)

Dio*_*ane 8

添加:body, html { height:100% }并设置内容元素的高度height:100%.