gif 加载器作为顶层居中

发布于 2024-08-05 16:17:30 字数 138 浏览 10 评论 0原文

我有一个 php 表单。提交此表单后,如果所有数据均有效,则执行 python 脚本,该脚本需要 5-10 秒。在这段等待期间,我希望在屏幕中间显示一个进度条(.gif)。如果我还可以“淡出”背景,使进度条像顶层,背景像后层,那就太好了。

谢谢。

I have a php form. After this form is submitted, if all data is valid, then it executes a python script which takes 5-10 seconds. For this wait period I would like to have a progress bar (.gif) displaying in the middle of the screen. If I could also 'fade away' the background so that the progress bar was like a top layer and the background a back layer, that would be great.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

同展鸳鸯锦 2024-08-12 16:17:30

您是否使用任何 javascript 库,例如 jQuery?我想在任何一个库中都会有十几个灯箱插件。即使你不想使用库,你也可以看一下他们的代码,而不是显示 DIV,只需显示你的 gif,如果你明白我的意思的话。

甚至还有一些专门为此目的构建的插件,例如 jQuery 的 BlockUI 插件。


做你想做的事情的基本算法是这样的:

  1. 启动 Ajax 请求
  2. 在整个页面上显示半透明的深色图像,中间有一个动画 gif。
  3. 监听 Ajax 响应
  4. 删除覆盖层和加载器 gif。

我假设您已经完成了步骤 1 和 3。第 4 步很简单。然而,第 2 步并不那么容易,但仍然不会太难。我无法告诉您自己执行此操作的代码,因为我过去只使用过灯箱插件。看看谷歌上的“简单灯箱”或类似的东西,因为你真正想要的只是最基本的功能。这篇博文讨论了 纯 CSS 灯箱 这将是帮助您设置叠加层样式的一个很好的起点。

Are you using any javascript libraries, such as jQuery? In any of the libraries, I'd imagine there'd be a dozen or so lightbox plugins floating about. Even if you don't want to use a library, you can take a look at their code, and instead of displaying a DIV, just display your gif, if you know what I mean.

There are even some plugins built specifically for this purpose, such as the BlockUI plugin for jQuery.


The basic algorithm for doing what you want goes like this:

  1. Start Ajax Request
  2. Display semi-transparent dark image over the whole page, with an animated gif in the middle.
  3. Listen for Ajax response
  4. Remove the overlay and loader gif.

I assume you already have steps 1 and 3 going alright. Step 4 is easy-peasy. Step 2 however isn't as easy, but still shouldn't be too hard. I couldn't tell you the code to do it myself, since I've just used lightbox plugins in the past. Take a look on Google for "simple lightbox" or something like that, since all you really want is the most basic functionality. This blog post talks about a CSS-only lightbox which would be a good starting point to help you style the overlay.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文