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

标签 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>

这是在页面加载时显示加载图形的代码。它显示在 GridView 上方。当网格包含大量行时,当我向下滚动页面时,我看不到加载图形。但是当我转到屏幕顶部时,我可以看到加载图形。如何在滚动页面时始终将其保持在屏幕中间?

请帮帮我。

最佳答案

我检查了我的旧答案,看看是否可以添加一些更现代的东西。在我较新的解决方案中,您不需要指定高度或宽度。这是一个更通用的解决方案。

.center {
   position: fixed;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
}

试试这个:

.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
}

关于javascript - 加载 Spinner - 即使在滚动页面时也始终保持在屏幕中间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31237971/

相关文章:

html - 如何仅使用 css 为选项提供填充

javascript - promise 的值究竟是如何更新的?

javascript - 在 Javascript 和 CSS 之间保持 DRY

html - 提交按钮不起作用

javascript - 关闭后 qtip2 位置发生变化

jquery - 使用 jQuery animate CSS opacity fade 和 @font-face 给 Internet Explorer 带来非常难看的字体渲染?

html - 如何显示标题文本后面的背景图像?

php - 使用uploadify最新版本上传视频

javascript - 在 selenium 中选择 SVG 标签内的 g

javascript - Spring RESTful GET方法具有相同的参数和不同的返回类型