100% 高度的关键是您需要一个包装器 div 围绕您的所有内容,该 div 也设置为min-height: 100%
. 这是您的代码,其中添加了额外的包装器(出于演示目的,我给了它一个红色背景):
<!DOCTYPE html>
<html>
<head>
<title>ActRecognitionWeb</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/backbone.js"></script>
<script src="js/underscore.js"></script>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<style type='text/css'>
html{
height: 100%;
}
body {
background-color: #FFF;
height: 100%;
margin: 0; padding: 0;
}
.wrap {min-height: 100%; background: red;}
#login-screen
{
background-image: url('img/login_background.jpg');
padding-top: 40px;
height: 100%;
padding: 60px;
padding-right: 200px;
margin-bottom: 30px;
font-size: 18px;
font-weight: 200;
line-height: 30px;
}
.container-fluid
{
padding-top: 40px;
height: 100%;
padding: 60px;
padding-right: 200px;
margin-bottom: 30px;
font-size: 18px;
font-weight: 200;
line-height: 30px;
}
#login-sidebar
{
text-align: right;
opacity:0.8;
padding-top: 10%;
}
.navbar .brand
{
padding-left: 30px;
}
h1 {
margin-bottom: 0;
font-size: 60px;
line-height: 1;
letter-spacing: -1px;
color: inherit;
}
</style>
</head>
<body>
<div class="wrap">
<div class="container">
<div class='navbar navbar-inverse navbar-fixed-top'>
<div class='navbar-inner' style="height: auto;" >
<a class="brand" href="#">ActRecognition</a>
<ul class="nav" data-bind="visible: loggedIn()">
<li class="active"><a href="#">Summary</a></li>
<li><a href="#">Challenges</a></li>
<li><a href="#">Routes</a></li>
</li>
</ul>
<ul class="nav pull-right" data-bind="visible: loggedIn()">
<li class="dropdown" >
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span data-bind="text: userName"></span>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">Settings</a></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#">Log Out</a></li>
</ul>
</ul>
</div>
</div>
</div>
</div>
</body>
<script type='text/javascript' src='js/knockout-2.2.1.js'></script>
<script src='js/viewModel.js'></script>
</html>
这里有一个很棒的具体细节教程:
http://www.sitepoint.com/forums/showthread.php?171943-CSS-FAQ-Tips-etc-Please-read-before-posting!&p=1243541#post1243541
如果您只是针对 IE8 及更高版本,则可以使用更简单的解决方案。