General / Posts /

CSS loading spinner with a semi-transparent background

68

I need a semi-transparent background that covers the whole page, with a semi-transparent spinner to indicate the page is still in loading process. I want a simple plain CSS solution. Anybody can show me how?

Vincent  3 years ago   viewed: 56069    

39 Answers

19
×

1. Add the following element in the page (anywhere):

<div id="cover-spin"></div>

2. Also add the following styles in the stylesheet:

#cover-spin { position:fixed; width:100%; left:0;right:0;top:0;bottom:0; background-color: rgba(255,255,255,0.7); z-index:9999; display:none; } @-webkit-keyframes spin { from {-webkit-transform:rotate(0deg);} to {-webkit-transform:rotate(360deg);} } @keyframes spin { from {transform:rotate(0deg);} to {transform:rotate(360deg);} } #cover-spin::after { content:''; display:block; position:absolute; left:48%;top:40%; width:40px;height:40px; border-style:solid; border-color:black; border-top-color:transparent; border-width: 4px; border-radius:50%; -webkit-animation: spin .8s linear infinite; animation: spin .8s linear infinite; }


How to Use

By default, the element will not be visible as it has been styled as {display:none;}

You can show it when you need it. For example:

<button onclick="$('#cover-spin').show(0)">Save</button>
Note: Above code is supposing that your page has the jQuery plugin.

Another Way to Use

You don't need to add the element into the page initially as shown in the beginning. And you can style it as {display:block;} instead of {display:none;}. You can dynamically add the element when you need it. For example:

<button onclick="$('#contentContainer').html('<div id=\'cover-spin\'></div>'); myAjaxSave();">Save</button>


DEMO

   Your update has been successfully saved.


Milo
  3 years ago
5

Thank you very much, it helped :)

Ihor   11 months ago
0

Thank you so much Milo!

I hope you always happy :)

levinbosz   28 days ago
4

Thanks for the post. Very helpful for me.

Saroj Rana
  one year ago
0

This is the pest site to get this kind of help! 

Damian
  2 days ago
3

@Milo, dude you are a hero thank you for sharing your knowledge. Did you generate that code yourself?

P.S

allow me to flex our team in Painting works hamilton

Frey   24 days ago
0

Milo is a super knowledgably person. Thank you! HVAC

Derreck
  2 days ago
0

Great work. Was very helpful ..

Virus
  3 months ago
1

Thanks again! Family Dentist 

Suriv
  2 days ago
0

Was very helpful .. Thanks a ton ! :) 

Swathi B N   10 months ago
0

 It helped 

Thank you very much :)

ankita
  8 months ago
0

Awesome! Very Helpful! it works perfect

Patrick
  7 months ago
0

He is the bomb! He helped me with my home work too! 

Swazy
  2 days ago
0
Awesome! Very Helpful! it works perfect
ANONYMOUS   6 months ago
0

great job with this article! Thank you


https://www.fayettevillegaragedoorrepairs.com/

Jason
  2 days ago
0

Thank you for this information, It is very useful for all.

Are you looking for PMP Certification in the USA then must joIn 4pmti today. They are the best institute for  PMP certification and CAPM & PMI training. You can check their website for more details about it. They offer many online PMP certification courses along with this.

https://www.4pmti.com/PMP-Certification-Requirements.aspx

Andrew Duke
  one month ago
0

Thank you for this blog. You're very detailed and your information was concrete

tyler Pawn
  2 days ago
0

Very unique information provide i really impress your article you have made some great content

wwe shop

kevinbear
  one month ago
0

Agreed! Thank you for this article Clean you carpets

StoneColdSteve
  2 days ago
0

Law Assignment Help by Law Assignment Writer (Certified Assignment Writer)

Law is the system of rules which a particular country and community that helps in regulating the actions of its members. It also helps in imposing the penalties if someone is doing bad to the country or nation. If you guys find law assignment very difficult and seeking law online assignment help service then you must hire law writers that is certified assignment writers

crystal
  one month ago
0

Thank you for. Amazing work

please check out my site. we are the Best Microblading in all the land

jason
  2 days ago
0
I now forgot how to make codes. It has been couple of years since I graduated. Thanks for this reference. Regards, roofers johns creek ga.
Fancypants   one month ago
0

It is a good read. Thank you for this! <a href="https://www.joliettreespecialists.com/">tree service</a>

Thomas Clark
  25 days ago
0

great read. Thanks again. 

Junk Removal

amberseo
  2 days ago
0

We not only provide Online Nursing Writing Services for our clients but help them understand Nursing Paper Writing Services procedures so that they can gain award winning Nursing Research Paper Writing Services knowledge.

florahwilliams   19 days ago
0

great job on this content. We needed this ! 

https://www.joplinfenceservices.com/

Joplin
  2 days ago
0

pretty good stuff concrete oahu

ricky   17 days ago
0

quality stuff right cheah! Tree Service

SlickRick
  2 days ago
0

Thank you! Really helpful. 

Iwan
  16 days ago
0

nice job on this post! Get yourself some awesome window Tinting from us. Click here 

Tony
  2 days ago
0

The most outstanding type of men's clothing is that is not expensive but still very much durable. This particular style of clothing can be found in several styles, and these include men's jackets, vests, shirts, and shoes. Even though the women have a wide variety of fashion, men have yet to discover all of the styles that they need. That is why there are many companies that market unique styles of clothing specifically for men that are created for them by designers. These designer brands also create jackets that are specifically designed for men.

Another unique fashion for men is their sporty type of clothing, particularly in the category of men's jackets and vests. These jackets come in many different styles, including short jackets, chaps, trousers, and polo shirts. Jackets come in many different materials, and the use of leather is the most commonly used in men's clothing. One of the hottest trends for this clothing is their vests. These are useful in all weather conditions, which makes them popular among male outdoor enthusiasts and joggers. It can help keep warm, and it can also act as a shield between your body and the elements if you feel the wind getting too much for you to handle.

Men also have many accessories that can further enhance their appearance, and many of them focus on the more unique materials. For example, a man might wear a pocket watch that is either a metal one or a plastic one. There are many other accessories that are specifically designed for men that range from cuff links to jewelry. The most common types of jewelry that are used for men are their rings, watches, and pendants.

ALi Khan   11 days ago
0

good stuff here! Web Design

joe
  2 days ago
0

www.417boom.com this is awesome stuff 

amy
  2 days ago
0

This is the first time that I visit here. I found so many exciting matters in this particular blog, One thing I would like to request you that pls keep posting such type of informative blog. Black Widow Costume

Kevin Peterson
  11 days ago
0

I appreciate this blog your blog is vert help full for me i really enjoyed this stuff dude. Miles Morales Hoodie

David Warner
  11 days ago
0

This is super cool! Thank you so much for sharing! concrete Helena MT, concrete Coeur D'Alene

Jerry Kimball
  10 days ago
0

It is very use full for us i am so glad to found this amazing stuff i really help full for me i have bookmark this post  James Bond Jacket

kevinbear
  6 days ago
-1

Thank you so much for sharing this topic for me I am searching about on this topic many days and At Tulsa Eastern Oklahoma Dental Care is a devoted dental care service providing the best services to maintain the oral health of their patient.

lyndawilliam
  4 days ago
-1

he used to have the s20s and he roofing contractor them for the v60s because they are cheaper cx would go back to those phones but he wants them at the same cost as the v60s which wont happen. 

Jason
  2 days ago

   

Your name*
Password
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question:
    • If your question is related to the General, click:

      Ask new question: General
    • Otherwise navigate to one of the following forum categories, and post your question there.

      ##