【问题标题】:How to add preloader loading gif to my website [closed]如何将预加载器加载 gif 添加到我的网站 [关闭]
【发布时间】:2018-09-19 06:59:45
【问题描述】:

我想在我的网站加载前最多 5 秒添加带有“正在加载”的 gif 图像的预加载器。试了很多方法都不行,各位大神能帮帮我吗?

参考:https://www.itchotels.in/。我想要这样的东西。提前致谢。

【问题讨论】:

  • 你可以做什么使网站在后台和动画完成时,例如。 5 秒,隐藏徽标和显示站点。

标签: css html bootstrap-4 preloader


【解决方案1】:

试试这个...

$(window).on('load', function() { // makes sure the whole site is loaded 
  $('#status').fadeOut(); // will first fade out the loading animation 
  $('#preloader').delay(350).fadeOut('slow'); // will fade out the white DIV that covers the website. 
  $('body').delay(350).css({'overflow':'visible'});
})
body {
  overflow: hidden;
}


/* Preloader */

#preloader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #fff;
  /* change if the mask should have another color then white */
  z-index: 99;
  /* makes sure it stays on top */
}

#status {
  width: 200px;
  height: 200px;
  position: absolute;
  left: 50%;
  /* centers the loading animation horizontally one the screen */
  top: 50%;
  /* centers the loading animation vertically one the screen */
  background-image: url(https://raw.githubusercontent.com/niklausgerber/PreLoadMe/master/img/status.gif);
  /* path to your loading animation */
  background-repeat: no-repeat;
  background-position: center;
  margin: -100px 0 0 -100px;
  /* is width and height divided by two */
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Preloader -->
<div id="preloader">
  <div id="status">&nbsp;</div>
</div>

<img width="100%" src='https://unsplash.it/3000/3000/?random' />

【讨论】:

  • 它首先显示网站然后加载器来然后网站加载。我希望任何访问我网页的人首先看到页面加载器,然后他们将看到网页
猜你喜欢
  • 2020-07-16
  • 1970-01-01
  • 1970-01-01
  • 2012-09-08
  • 1970-01-01
  • 2016-01-20
  • 1970-01-01
  • 2020-01-07
  • 1970-01-01
相关资源
最近更新 更多