在页面加载时显示图像
Display image while page onLoad
在我的HTML
页面中,我使用某些选项加载,处理,在页面中加载外部.txt
文件 因为此过程需要一些时间来加载我需要显示图像,直到过程结束
我找到了这个脚本
<script>
// Put an animated GIF image insight of content
$("#content").empty().html('<img src="http://www.website.com/images/loading.gif" />');
// Make AJAX call
$("#content").load("http://website.com/page.php")
</script>
因为我使用许多进程,如页面加载处理加载 txt 文件
那么如何在上述提及过程中降低页面透明度和显示图像(.gif)
这是一个有效的 CSS 吹泡加载微调器。您甚至不需要上传任何其他内容。只需简单地定位要显示微调器的字段即可。并在必要时使用.show()
和.hide()
显示和隐藏微调器。
参考
$('.loader').show(); //show
$("#content").load("http://website.com/page.php") {
$('.loader').delay(1000).hide(); //hide
}
.loader:before,
.loader:after,
.loader {
display: none;
border-radius: 50%;
width: 2.5em;
height: 2.5em;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation: load7 1.8s infinite ease-in-out;
animation: load7 1.8s infinite ease-in-out;
}
.loader {
margin: 8em auto;
font-size: 10px;
position: relative;
text-indent: -9999em;
-webkit-animation-delay: 0.16s;
animation-delay: 0.16s;
}
.loader:before {
left: -3.5em;
}
.loader:after {
left: 3.5em;
-webkit-animation-delay: 0.32s;
animation-delay: 0.32s;
}
.loader:before,
.loader:after {
content: '';
position: absolute;
top: 0;
}
@-webkit-keyframes load7 {
0%, 80%, 100% {
box-shadow: 0 2.5em 0 -1.3em #ffffff;
}
40% {
box-shadow: 0 2.5em 0 0 #FFF;
}
}
@keyframes load7 {
0%, 80%, 100% {
box-shadow: 0 2.5em 0 -1.3em #ffffff;
}
40% {
box-shadow: 0 2.5em 0 0 #FFF;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="loader">Loading...</div>
更新:
另一种方法是:
- 添加 html 元素,您将在其中显示加载器。(例如 #example)
- 将
display: hidden
添加到#example
- 在要加载或加载之前,将
.show()
添加到#example
- 阿贾克斯调用
- 调用请求后
.hide()
#example
相关文章:
- 从桌面读取python文件时高亮显示代码
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 如何在生成下载文件时显示加载动画
- React重新渲染但未显示正确的组件
- nodejs-expressjs上传图像并显示它们
- 使用JSP从服务器检索和显示图像
- 音频控件在mouseover上显示,在mouseout上淡出
- 让文本输入幻灯片显示输入时的新文本输入?然后向后滑动
- 使用电话间隙在Android应用程序中显示SQL Lite的数据
- 显示5秒后隐藏潜水
- 画廊图像未显示
- 不显示带有本地json文件数据的谷歌地图脚本
- 如何将json数据显示为html
- 谷歌地图不是以HTML显示,而是在JS Fiddle上工作
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- 高亮显示时编辑文本大小和颜色
- 有时数据是't显示在浏览器中
- 当鼠标悬停在文本中的单词上时显示警报
- 角度图表;t显示在我的页面中
- 显示图工具提示显示x轴的最后日期值,而不是当前值