所以我有一个问题,我认为是相当普遍的,但我还没有找到一个好的解决方案。我想使覆盖div覆盖整个页面...而不仅仅是视口。我不明白为什么这是很难做...我已经尝试设置身体,HTML高度为100%等,但这是行不通的。以下是我迄今为止:使Div覆盖整个页面(不只是视口)?
<html>
<head>
<style type="text/css">
.OverLay { position: absolute; z-index: 3; opacity: 0.5; filter: alpha(opacity = 50); top: 0; bottom: 0; left: 0; right: 0; width: 100%; height: 100%; background-color: Black; color: White;}
body { height: 100%; }
html { height: 100%; }
</style>
</head>
<body>
<div style="height: 100%; width: 100%; position: relative;">
<div style="height: 100px; width: 300px; background-color: Red;">
</div>
<div style="height: 230px; width: 9000px; background-color: Green;">
</div>
<div style="height: 900px; width: 200px; background-color: Blue;"></div>
<div class="OverLay">TestTest!</div>
</div>
</body>
</html>
我还开放给在JavaScript的解决方案如果存在的话,但我宁愿只使用一些简单的CSS。
能读也更这里:http://stackoverflow.com/questions/1938536/how-to-make-the-height-really-100/1938592# 1938592 – 2010-05-17 22:13:38
这可以通过jQuery实现吗? – 2016-04-26 03:52:29