加载微调器 - 即使在滚动页面时也始终保持在屏幕中间

时间:2015-07-06 04:51:41

标签: javascript jquery html css asp.net-mvc

<div id="Dvloading" style="float: left;">
        <i id="loadingSpinner" class="icon-spinner icon-spin blue" style="margin-left: 50%; position:absolute ; margin-top: 25%; z-index: 1000; font-size: 800%;"></i>
</div>

这是在页面加载时显示加载图形的代码。它显示在网格视图上方。当网格由大量行组成时,当我向下滚动页面时,我无法看到加载图形。但是当我走到屏幕顶部时,我可以看到加载图形。即使滚动页面,我如何将它始终保持在屏幕中间?

请帮帮我。

2 个答案:

答案 0 :(得分:9)

试试这个:

.centered {
  position: fixed;
  top: 50%;
  left: 50%;
  margin-top: -50px; //Half of the height of the loading graphic
  margin-left: -50px; //Half of the width of the loading graphic
}

答案 1 :(得分:0)

这是我的解决方案...

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Untitled</title>

  <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2021.2.616/styles/kendo.common.min.css">
  <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2021.2.616/styles/kendo.rtl.min.css">
  <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2021.2.616/styles/kendo.default.min.css">
  <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2021.2.616/styles/kendo.mobile.all.min.css">

  <script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
  <script src="https://kendo.cdn.telerik.com/2021.2.616/js/angular.min.js"></script>
  <script src="https://kendo.cdn.telerik.com/2021.2.616/js/jszip.min.js"></script>
  <script src="https://kendo.cdn.telerik.com/2021.2.616/js/kendo.all.min.js"></script>
</head>
<body>
  <style>    
    body {
      height: 100%;
      position: relative;
    }

    .k-loading-image{
      position: fixed;
    }
    
    .longDiv {
      height:1500px;
      background: red;
    }
  </style>

  <div class="longDiv">This is a long DIV...</div>
  
  <script>
    const showBusyIndicator = (show) => kendo.ui.progress($("body"), show);
    $(document).ready(showBusyIndicator(true));
  </script>
</body>
  
</html>