我使用CSS和JavaScript來鎖定屏幕,但我不知道爲什麼鎖定面板與屏幕寬度不一樣,你有什麼想法嗎? 這裏是HTML源代碼,你可以在下面找到javascript代碼,有人幫我嗎?爲什麼沒有覆蓋整個屏幕寬度?
的JavaScript:
function FreezeScreen(msg) {
scroll(0,0);
var outerPane = document.getElementById('FreezePane');
var innerPane = document.getElementById('InnerFreezePane');
if (outerPane) outerPane.className = 'FreezePaneOn';
if (innerPane) innerPane.innerHTML = msg;
}
HTML:
<body>
<div align="center" id="FreezePane" class="FreezePaneOff">
<div id="InnerFreezePane" class="InnerFreezePane"> </div>
</div>
CSS:
.FreezePaneOff {
visibility: hidden;
display: none;
position: absolute;
top: -100px;
left: -100px;
}
.FreezePaneOn {
position: absolute;
top: 0px;
left: 0px;
visibility: visible;
display: block;
width: 100%;
height: 100%;
background-color: #666;
z-index: 999;
filter:alpha(opacity=85);
-moz-opacity:0.85;
padding-top: 20%;
}
.InnerFreezePane {
text-align: center;
width: 66%;
background-color: #171;
color: White;
font-size: large;
border: dashed 2px #111;
padding: 9px;
}
請提供您的HTML –
嘗試使用'高度:100vh'和'寬度:100vw' – Baruch
這將是同樣的結果。 – mikezang