Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a transparent loading overlay

Tags:

html

css

Using the same markup (shown below), is it possible to add a style which creates a transparent background overlay i.e. a loading overlay? When I try to add a background to .loading CSS it only adds it to the background of the .loading element and not the body. The style .loading gets removed (via jQuery) so ideally I want the overlay to be somehow be connected to .loading, if possible?

HTML

<div class=loading style-2>
    content
</div>

CSS

.loading {
  position: fixed;
  top: 1px;

  margin: 5em;
  border-width: 30px;
  border-radius: 50%;
  -webkit-animation: spin 1s linear infinite;
     -moz-animation: spin 1s linear infinite;
       -o-animation: spin 1s linear infinite;
          animation: spin 1s linear infinite;
  }

.style-1 {
  border-style: solid;
  border-color: #444 transparent;
  }

.style-2 {
  border-style: double;
  border-color: #ccc transparent;
  }

.style-3 {
  border-style: double;
  border-color: #444 #fff #fff;
  }

@-webkit-keyframes spin {
  100% { -webkit-transform: rotate(359deg); }
  }

@-moz-keyframes spin {
  100% { -moz-transform: rotate(359deg); }
  }

@-o-keyframes spin {
  100% { -moz-transform: rotate(359deg); }
  }

@keyframes spin {
  100% {  transform: rotate(359deg); }
  }
like image 702
Prometheus Avatar asked Dec 23 '13 10:12

Prometheus


People also ask

How do I make a background image overlay?

We can use the property to provide an overlay to the background image. We can use the background-blend-mode property after setting the background image. For example, create a div in HTML. In CSS, set the background image using the url() function and set the no-repeat and fixed values in the background property.

What is overlay loading?

To overload is to load an excessive amount in or on something, such as an overload of electricity which shorts out the circuits. Overloading causes a "Too much!" situation. To overload is to push something or someone too far.


Video Answer


1 Answers

I was able to do a loading overlay but only with the addition of an extra container.

<div class="loading style-2"><div class="loading-wheel"></div></div>

http://jsfiddle.net/8k2NV/2/

like image 94
LeBen Avatar answered Nov 04 '22 02:11

LeBen