Table of Contents
Example
Loader in CSS
Example of the most common form of loader in CSS
Add logo in loader
algorithm
in conclusion
Home Web Front-end CSS Tutorial How to set logo in loader using CSS?

How to set logo in loader using CSS?

Sep 24, 2023 pm 08:17 PM

To start answering this question, we first need to create a "Loader". Any animation that notifies the user or visitor that a page is loading and will take a few seconds to complete is called a loader.

Most of the time, loaders come in handy when a website takes too long to retrieve results. If a particular website doesn't have a CSS loader, users will think it's not responding at all while it's loading.

As a result, adding a CSS loader to a web page will cause the user to be distracted or wait a while for the page to load properly. Rather than giving the impression that the site is unresponsive, a simple animation shows that the site is still retrieving results and that the page will be ready in a few seconds.

You can use CSS to add styles, animations, or any other form of styling to create a loader.

Example

We will now use CSS to create the most common form of loader on the internet.

<!DOCTYPE html>
<html>
<head>
   <title>Example of a loader using CSS</title>
   <style>
      h1 {
         color: rgb(0, 128, 111);
      }
      .loader {
         display: block;
         position: absolute;
         width: 15px;
         height: 15px;
         left: calc(50% - 1.25em);
         border-radius: 1.25em;
         transform-origin: 1.25em 2.25em;
         animation: rotateAnimation;
         animation-iteration-count: infinite;
         animation-duration: 1.85s;
      }
      @keyframes rotateAnimation {
         from {
            transform: rotateZ(0deg);
         }
         to {
            transform: rotateZ(360deg);
         }
      }
      .item1 {
         animation-delay: 0.12s;
         background-color: #1b7842;
      }
      .item2 {
         animation-delay: 0.22s;
         background-color: #239b53;
      }
      .item3 {
         animation-delay: 0.32s;
         background-color: #2ecc72;
      }
      .item4 {
         animation-delay: 0.42s;
         background-color: #82e0a0;
      }
      .item5 {
         animation-delay: 0.52s;
         background-color: #d5f5de;
      }
   </style>
</head>
<body>
   <center>
      <h1 id="Loader-in-CSS">Loader in CSS</h1>
      <h4 id="Example-of-the-most-common-form-of-loader-in-CSS">Example of the most common form of loader in CSS</h4>
      <div>
         <div class="loader item1"></div>
         <div class="loader item2"></div>
         <div class="loader item3"></div>
         <div class="loader item4"></div>
         <div class="loader item5"></div>
      </div>
   </center>
</body>
</html>
Copy after login

Example

This is another form of loader that animates on the horizontal axis.

<!DOCTYPE html>
<html>
<head>
   <title>Example of a loader using CSS</title>
   <style>
      h1 {
         color: rgb(0, 128, 111);
      }
      .loader {
         display: block;
         position: absolute;
         width: 150px;
         height: 15px;
         left: calc(58% - 5.25em);
         transform-origin: 2px 20px;
         animation: rotateAnimation;
         animation-iteration-count: infinite;
         animation-duration: 2.85s;
      }
      @keyframes rotateAnimation {
         from {
            transform: rotateY(55deg);
         }
         to {
            transform: rotateY(360deg);
         }
      }
      .item1 {
         animation-delay: 0.12s;
         background-color: #1b7842;
      }
      .item2 {
         animation-delay: 0.22s;
         background-color: #239b53;
      }
      .item3 {
         animation-delay: 0.32s;
         background-color: #2ecc72;
      }
      .item4 {
         animation-delay: 0.42s;
         background-color: #82e0a0;
      }
      .item5 {
         animation-delay: 0.52s;
         background-color: #d5f5de;
      }
   </style>
</head>
<body>
   <center>
      <h1 id="Loader-in-CSS">Loader in CSS</h1>
      <h4 id="Example-of-the-most-common-form-of-loader-in-CSS">Example of the most common form of loader in CSS</h4>
      <div>
         <div class="loader item1"></div>
         <div class="loader item2"></div>
         <div class="loader item3"></div>
         <div class="loader item4"></div>
         <div class="loader item5"></div>
      </div>
   </center>
 </body>
</html>
Copy after login

Add logo in loader

Now that we know how to make a loader in CSS, we will move on to how to add a logo to the loader we just created.

Let's first try to understand why we might need to add a logo inside the loader. A logo is the mark and identity of a brand, which adds a personal touch to the user experience. Nowadays, all websites use personalization loaders that have a positive impact on their brand every time a user lands on their website.

algorithm

The algorithm we will follow to create a loader with embedded logo is as follows -

  • Step 1 - To include our loader, we will build an HTML file and add an HTML div to the body of the file.

  • Step 2 - To provide our logo and loader animation, we will write a CSS file or embed it using style tags.

  • Step 3 - Insert the logo using the How to set logo in loader using CSS? tag inside the div tag so that it now displays in the loader class

Given below are the properties we can use for the loader -

  • We will customize the border, color, height, and width according to the logo, which will greatly improve the overall consistency and increase the brand originality.

  • To add a gradual change animation, we will utilize the @keyframes rule in CSS.

  • Then, to make the loader rotate, we will use the CSS Transform property.

We will design the size of the logo image so that it is smaller than or equal to the size of the loader. We'll add an animation style in the opposite direction to counteract the effect of the logo's rotation.

Example

Below is an example of adding a loader to a website using the algorithm above.

<!DOCTYPE html>
<html lang="en">
<head>
   <style type="text/css">
      .loaderClass {
         border: 12px solid #dcd7d7;
         border-top: 12px solid #04802f;
         border-radius: 50%;
         width: 120px;
         height: 120px;
         animation: SpinLoader 2.5s linear infinite;
      }
      .loaderClass img {
         height: 120px;
         width: 120px;
         border-radius: 50%;
         animation: LogoModify 2.5s linear infinite;
      }
      @keyframes SpinLoader {
         0% {
            transform: rotate(0deg);
         }
         100% {
            transform: rotate(360deg);
         }
      }
      @keyframes LogoModify {
         0% {
            transform: rotate(360deg);
         }
         100% {
            transform: rotate(0deg);
         }
      }
   </style>
</head>
<body>
   <div class="loaderClass">
      <img src="/static/imghw/default1.png"  data-src="https://img.php.cn/upload/article/000/887/227/169555783454341.jpg"  class="lazy" alt="How to set logo in loader using CSS?">
   </div>
</body>
</html>
Copy after login

in conclusion

All in all, setting the logo in the loader using CSS is a simple task. All you need to do is set the width and height of your logo and then add it as the background image of your loader using the "background-image" attribute. You can also adjust its position using the "background-position" or "margin" properties and customize it further with other styling options like borders, box-shadow, etc. With some basic knowledge of CSS, you can easily create a beautiful loader with a logo. time!

The above is the detailed content of How to set logo in loader using CSS?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Working With GraphQL Caching Working With GraphQL Caching Mar 19, 2025 am 09:36 AM

If you’ve recently started working with GraphQL, or reviewed its pros and cons, you’ve no doubt heard things like “GraphQL doesn’t support caching” or

Making Your First Custom Svelte Transition Making Your First Custom Svelte Transition Mar 15, 2025 am 11:08 AM

The Svelte transition API provides a way to animate components when they enter or leave the document, including custom Svelte transitions.

Show, Don't Tell Show, Don't Tell Mar 16, 2025 am 11:49 AM

How much time do you spend designing the content presentation for your websites? When you write a new blog post or create a new page, are you thinking about

Building an Ethereum app using Redwood.js and Fauna Building an Ethereum app using Redwood.js and Fauna Mar 28, 2025 am 09:18 AM

With the recent climb of Bitcoin’s price over 20k $USD, and to it recently breaking 30k, I thought it’s worth taking a deep dive back into creating Ethereum

What the Heck Are npm Commands? What the Heck Are npm Commands? Mar 15, 2025 am 11:36 AM

npm commands run various tasks for you, either as a one-off or a continuously running process for things like starting a server or compiling code.

How do you use CSS to create text effects, such as text shadows and gradients? How do you use CSS to create text effects, such as text shadows and gradients? Mar 14, 2025 am 11:10 AM

The article discusses using CSS for text effects like shadows and gradients, optimizing them for performance, and enhancing user experience. It also lists resources for beginners.(159 characters)

Creating Your Own Bragdoc With Eleventy Creating Your Own Bragdoc With Eleventy Mar 18, 2025 am 11:23 AM

No matter what stage you’re at as a developer, the tasks we complete—whether big or small—make a huge impact in our personal and professional growth.

Let's use (X, X, X, X) for talking about specificity Let's use (X, X, X, X) for talking about specificity Mar 24, 2025 am 10:37 AM

I was just chatting with Eric Meyer the other day and I remembered an Eric Meyer story from my formative years. I wrote a blog post about CSS specificity, and

See all articles