我試圖讓一個 div 覆寫我的整個頁面。目前,問題是它只覆寫了視口的大小(例如 1920x1080px)。
這是我目前使用的 div 的 CSS:
#cursor-container {
position: absolute;
z-index: 99999;
pointer-events: none;
overflow-x: auto;
background-color: rgba(0, 0, 0, 0.25);
top: 0;
left: 0;
bottom: 0;
right: 0;
height: 100%;
width: 100%;
}
目前,它看起來像這樣:

但它應該是這樣的:

我怎樣才能解決這個問題?
uj5u.com熱心網友回復:
首先,確保div您使用的是body元素的子元素,然后將位置更改為position: fixed;,
#cursor-container {
position: fixed;
top: 0;
left: 0;
margin: 0;
padding: 0;
height: 100%;
width: 100%;
z-index: 99999;
pointer-events: none;
overflow-x: auto;
background-color: rgba(0, 0, 0, 0.25);
}
這將確保您的 div 保持固定在螢屏上,即使頁面向下滾動并且它會覆寫整個螢屏
此外,將父級的寬度和高度也設定為 100%,
html, body {
width: 100%;
height: 100%;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/360129.html
上一篇:修復具有特定樣式的html表格
