Creating a Spinner with HTML and CSS

Tiempo de lectura: < 1 minuto

Reading Time: < 1 minute

Good morning, to create a spinner (a spinning loading indicator) with HTML and CSS, you can follow these steps:

First, create an empty div to which we will later give the appearance of a spinner to add to our projects.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="boton_loader.css">
    <title>Loader / Spinner for devcodelight</title>
</head>

<body>
    <div class="spinner"></div>
</body>

</html>

In the CSS, we add styles to the div element to give it the appearance of a spinner. For example:

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgb(169, 5, 136);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spinner 1s infinite linear;
}

@keyframes spinner {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}
  

Below is the result:

Leave a Comment