search
HomeWeb Front-endCSS TutorialHow to make the pseudo progress bar display as a gif image on the page

For convenience at work, we need to add some effects. This article will tell you how to display a gif image on the page with a pseudo progress bar. Friends who are interested can refer to it. I hope it can help. you.

In a recent project, after clicking on an operation, it took a little longer because there were more things done in the background. During this process, no changes can be seen at the front desk. In order to prevent customers from clicking the button again after clicking it, a gif image is added to the page after clicking the button for the first time, just like a progress bar. After the function is completed, delete the image.

1 gif image

How to make the pseudo progress bar display as a gif image on the page

2 After clicking the button, the front-end JS code adds an img tag and a DIV layer for masking:

var tb_pathToImage = "Images/loadingAnimation.gif";
imgLoader = new Image(); //  image对象
    imgLoader.src = tb_pathToImage;
    $("body").append("<div id=&#39;Image_load&#39;><img  src="/static/imghwm/default1.png"  data-src="https://img.php.cn//upload/image/282/102/372/1537868158709779.jpg?x-oss-process=image/resize,p_40"  class="lazy"  src=&#39;" + imgLoader.src + "&#39; / alt="How to make the pseudo progress bar display as a gif image on the page" ></div>"); //page中增加Img
    $(&#39;#Image_load&#39;).show(); //show loader
    $("body").append("<div id=&#39;pageover&#39; class=&#39;pageover_bg&#39; ></div>");  //增加遮罩层

3 Also add the corresponding CSS code:

.pageover_bg {	
        background-color:#000;
    	filter:alpha(opacity=75);	
    	-moz-opacity: 0.75;	
    	opacity: 0.75;	
    	}	
 #Image_load{	
     position: fixed;	
     display:none;	
     height:13px;	
     width:208px;	
     z-index:103;	
     top: 50%;	
     left: 50%;	
     margin: -6px 0 0 -104px; /* -height/2 0 0 -width/2 */	
     }

4 After the button event response is completed, remove the IMG and DIV layers

$(&#39;#Image_load&#39;).remove();           
        $(&#39;#pageover&#39;).remove();

Rendering:

How to make the pseudo progress bar display as a gif image on the page

The above is the detailed content of How to make the pseudo progress bar display as a gif image on the page. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
'Pretty' is in the eye of the beholder'Pretty' is in the eye of the beholderApr 23, 2025 am 09:40 AM

Yay, let's jump for text-wrap: pretty landing in Safari Technology Preview! But beware that it's different from how it works in Chromium browsers.

CSS-Tricks Chronicles XLIIICSS-Tricks Chronicles XLIIIApr 23, 2025 am 09:35 AM

This CSS-Tricks update highlights significant progress in the Almanac, recent podcast appearances, a new CSS counters guide, and the addition of several new authors contributing valuable content.

Tailwind's @apply Feature is Better Than it SoundsTailwind's @apply Feature is Better Than it SoundsApr 23, 2025 am 09:23 AM

Most of the time, people showcase Tailwind's @apply feature with one of Tailwind's single-property utilities (which changes a single CSS declaration). When showcased this way, @apply doesn't sound promising at all. So obvio

Feeling Like I Have No Release: A Journey Towards Sane DeploymentsFeeling Like I Have No Release: A Journey Towards Sane DeploymentsApr 23, 2025 am 09:19 AM

Deploying like an idiot comes down to a mismatch between the tools you use to deploy and the reward in complexity reduced versus complexity added.

So, You Want to Give Up CSS Pre- and Post-Processors...So, You Want to Give Up CSS Pre- and Post-Processors...Apr 23, 2025 am 09:18 AM

There was once upon a time when native CSS lacked many essential features, leaving developers to come up with all sorts of ways to make CSS easier to write over the years.

A New 'Web' Readiness ReportA New 'Web' Readiness ReportApr 23, 2025 am 09:14 AM

HTML 5 Readiness was a site that showed through a rainbow of colors the browser support for several web features. What about a new version?

Crafting Strong DX With Astro Components and TypeScriptCrafting Strong DX With Astro Components and TypeScriptApr 23, 2025 am 09:10 AM

One thing we can do to help teams code consistently is provide type-checking so that all of the configurable options for a specific component are available while coding. Bryan demonstrates how he does this with TypeScript when working with Astro comp

Simulating Mouse MovementSimulating Mouse MovementApr 22, 2025 am 11:45 AM

If you've ever had to display an interactive animation during a live talk or a class, then you may know that it's not always easy to interact with your slides

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!