您的位置:首页技术文章
文章详情页

javascript - position fixed;设置了height 100 却不是浏览器可视窗口的宽高,求大神释疑。

浏览:71日期:2023-04-17 10:07:39

问题描述

设置了如下css样式的代码,但是显示的高度不是全屏,如图。

.ss_hide{ position: fixed; background: rgba(0,0,0,.2); height: 100%; width: 100%;}

javascript - position fixed;设置了height 100 却不是浏览器可视窗口的宽高,求大神释疑。

问题解答

回答1:

建议全屏使用

top: 0;bottom: 0;left: 0;right: 0;回答2:

看一下你body和html所占的大小是否全屏。或者高100vh宽100vw

回答3:

还得加上 top:0;left:0;

回答4:

绝对定位脱离文档流了吧 既然都绝对定位了 top:0;left:0;right:0;bottom:0; 刚好覆盖屏幕

标签: JavaScript