jQuery fadein 效果转移到另一个页面

jQuery fadein effect to transfer to another page

我正在尝试设置加载页面,并且在转到 index.html 页面之前将超时设置为 5 秒。 我想通过一些基本的淡入淡出过渡到此页面,我想知道我该怎么做?

我目前的代码是:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title> Go Post - HomePage </title>
        <link rel="stylesheet" href="includes/style.css">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script>
            setTimeout(function(){
                window.location='index.html';
            }, 3000);
        </script>
    </head>

    <body>
        <div class="load"></div>
    </body>
</html>

您可以通过 jquery fadeOut 简单地做到这一点。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title> Go Post - HomePage </title>
        <link rel="stylesheet" href="includes/style.css">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <!-- Import jquery -->
        <script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
        <script>
            setTimeout(function(){
                $('html').fadeOut(
                    500,  // animation time
                    function(){
                        // action will do after the animation
                        window.location='index.html';  
                    }
                );
            }, 3000);
        </script>
    </head>

    <body>
        <div class="load"></div>
    </body>
</html>

试试下面的方法

在HTML中添加div

<div id="preloader">
</div>

jQuery

$(function() {

  setTimeout(function() {
    $('#preloader').fadeOut('slow', function() {
      window.location = "https://google.com";
    });

  }, 5000);

});

CSS:

div#preloader {
  background: url("http://www.mytreedb.com/uploads/mytreedb/loader/ajax_loader_blue_512.gif") no-repeat scroll center center #000000;
  height: 100%;
  position: fixed;
  width: 100%;
  z-index: 999;
}

演示:http://codepen.io/anon/pen/gPqLPX