内部div全屏有三个因素会导出无法全屏:
- 其直系父节点的overflow必须是visible或者不配置。当overflow为auto时。浏览器的理解是不同的,IE认为内部所有的节点只要溢出都应该显示滚动条。谷歌及火狐认为内部除了绝对定位以外的所有节点溢出时才应该显示滚动条。
- 其直系绝对定位的父节点是否配置z-index,IE下必须配置,谷歌及火狐下无所谓。
- 其直系父节点中有relative相对定位,则其全屏时的top、left的计算方式应该依照该节点计算。
下面是一个测试例子:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>overflow test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
*{margin:0px;padding:0px;font-size:9pt;font-family:monospace,Courier,"Courier New";}
.superDiv{position:absolute;top:10px;left:20px;width:150px;height:70px;line-height:20px;text-align:center;background:#FF80C0;z-index:3;overflow:visible;}
.super2Div{position:absolute;top:10px;left:180px;width:150px;height:70px;line-height:20px;text-align:center;background:#FF8080;overflow:visible;}
.subDiv{margin:0px auto;width:130px;height:40px;background:#DDFFFF;overflow:visible;}
.throughDiv{position:absolute;top:30px;left:-10px;width:330px;height:20px;line-height:20px;background:#44C2FF;z-index:3;overflow:hidden;}
</style>
</head>
<body>
<div class="superDiv">
super
<div class="subDiv">
<div class="throughDiv">
inside div through all div
</div>
</div>
</div>
<div class="super2Div">
super's brothers
<div class="subDiv"></div>
</div>
</body>
</html>