1

我正在使用 Bootstrap 做一个非常简单的登录页面。这个想法是让一个英雄单元文本元素覆盖整个页面,而不管窗口大小。width: 100%;CSS 指令效果很好,但height: 100%;没有任何效果——英雄单元元素仍然高约 200 像素,并附在窗口顶部。如何将英雄单位的高度设置为 100%?提前致谢。

4

2 回答 2

4

您必须设置height:100%onhtmlbody标签,如果 hero div 有父级,它也需要它。

示例http://jsfiddle.net/xExSE/

于 2013-01-09T20:31:22.703 回答
0

这似乎工作正常:

<html>
<head>
  <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->

  <!-- css -->
  <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/css/bootstrap-combined.min.css" />
  <style>
    .hero-unit {
      height: 100%;
      background-color: green;
    }
  </style>
</head>

<body>
    <div class="hero-unit">
      <h1>Full Page Hero!</h1>
    </div>
</body>
</html>
于 2013-01-09T20:44:51.907 回答