gpt4 book ai didi

jquery - 如何知道屏幕的高度?用于加载屏幕

转载 作者:太空宇宙 更新时间:2023-11-04 05:55:13 26 4
gpt4 key购买 nike

我正在制作加载屏幕,在页面高度超过 100% 之前效果很好,

CSS

.Loading {
position: absolute;
left: 0;
top:0;
background-color: #141414;
width: 100%;
height: 100%;
z-index: 1;
}

如何检测所有屏幕的实际高度?或者制作加载屏幕的最佳方法是什么?

Jquery//如果需要

$(document).ready(function(){
RemoveLoader();
});

function RemoveLoader(){
$(".Loading").animate({opacity:"0"},"slow",function(){
$(".Loading").remove();
});
}

最佳答案

你有一个选项可以从你的页面中删除滚动条。

您可以默认在 body 中定义 overflow:hidden;,当您删除加载程序时,也会删除 body 样式属性。

演示在您可以查看的片段中。

$(document).ready(function(){
RemoveLoader();
});

function RemoveLoader(){
$(".Loading").animate({opacity:"0"},"slow",function(){
$(".Loading").remove();
$('body').removeAttr('style');
});
}
.Loading{
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100vw;
height: 100vh;
z-index: 9999;
background-color: gray;
}
<body style="overflow: hidden;">
<div class="Loading"></div>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<p>your content</p>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</body>

谢谢你...

关于jquery - 如何知道屏幕的高度?用于加载屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57883980/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com