Image Overlay Preloader using DIV in CSS

In this tutorial, we will create a Image Overlay Preloader Using DIV In CSS. It provides a friendly user interface using Bootstrap and CSS. We create a CSS snippet for displaying a preloader over div content. And its not only for the list of content, you can use it for every case where you want to overlay something on the content. Overlaying image on div is a most used featured. To fetch the content server takes some time and user does not understand what happening behind the scene. So, if you display a loading image over the content list, it will helpful for the user to understand the data loading process. See the example code below.

Sample Code

Index.html - is the html form for the design for the web page and for the content of the resources.
  1. <!DOCTYPE>
  2. <title>Image Overlay Preloader Using DIV In CSS</title>
  3. <link rel="stylesheet" href="css/style.css">
  4. <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
  5. <script src="js/jquery.min.js"></script>
  6. <script src="bootstrap/js/bootstrap.min.js"></script>
  7. </head>
  8. <nav class="navbar navbar-inverse">
  9. <div class="container-fluid">
  10. <ul class="nav navbar-nav">
  11. <li><a href=""><b>Sourcecodester</b></a></li>
  12. <li class="active"><a href="#">HTML</a></li>
  13. <li><a href="#">CSS</a></li>
  14. <li><a href="#">JAVASCRIPT</a></li>
  15. <li><a href="#">PHP</a></li>
  16. <li><a href="#">SQL</a></li>
  17. </ul>
  18. </div>
  19. </nav><br/><br/><br/><br/>
  20. <div class="container" align="center">
  21. <div class="overlay">
  22. <div class="overlay-content">
  23. <img src="images/loading.gif" alt="Loading..."/>
  24. </div>
  25. </div>
  26. <div class="col-span">
  27. <h4>You're Future Is Created By What You Do Today, Not Tomorrow.</h4>
  28. <img src="images/img.jpg" class="img-rounded" alt="You're Future Is Created By What You Do Today, Not Tomorrow" width="304" height="236">
  29. </div>
  30. <div class="col-span">
  31. <h4>Learn and Earn.</h4><br>
  32. <img src="images/img1.jpg" class="img-circle" alt="Learn and Earn" width="304" height="236">
  33. </div>
  34. <div class="col-span">
  35. <h4>Men In The City.</h4><br>
  36. <img src="images/img2.jpg" class="img-thumbnail" alt="Men In The City" width="304" height="236">
  37. </div>
  38. </div>
  39. </body>
  40. </html>
Style.css - And this script is for the loading/preloader of the images or for the content to think that the background content is in the process.
  1. .container{
  2. position: relative;
  3. width:52%;
  4. }
  5. .overlay{
  6. position: absolute;
  7. left: 0;
  8. top: 0; right: 0;
  9. bottom: 0;
  10. z-index: 2;
  11. background-color: rgba(255,255,255,0.8);
  12. }
  13. .overlay-content {
  14. position: absolute;
  15. transform: translateY(-50%);
  16. -webkit-transform: translateY(-50%);
  17. -ms-transform: translateY(-50%);
  18. top: 50%;
  19. left: 0;
  20. right: 0;
  21. text-align: center;
  22. color: #555;
  23. }
Hope that you like my tutorial. And don't forget to Like and Share this to your friends. Enjoy Coding.

Add new comment