Advertisement
ucielsola

Ejemplo Loader

Apr 18th, 2022 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.91 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.     <head>
  4.         <meta charset="UTF-8" />
  5.         <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6.         <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7.         <title>Document</title>
  8.     </head>
  9.     <style>
  10.         * {
  11.             margin: 0;
  12.             padding: 0;
  13.         }
  14.         body {
  15.             position: relative;
  16.             min-height: 100vh;
  17.             display: grid;
  18.             place-content: center;
  19.             background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%);
  20.         }
  21.  
  22.         h1 {
  23.             font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
  24.             font-size: 1.5rem;
  25.         }
  26.         .loader {
  27.             position: fixed; // importante para evitar scroll
  28.             min-height: 100vh;
  29.             min-width: 100vw;
  30.             display: grid;
  31.             place-content: center;
  32.             background-image: linear-gradient(120deg, #f093fb 0%, #f5576c 100%);
  33.         }
  34.  
  35.         .fade-out {
  36.             opacity: 0;
  37.             transition: opacity 300ms ease-in-out;
  38.         }
  39.  
  40.         .lds-dual-ring {
  41.             display: inline-block;
  42.             width: 80px;
  43.             height: 80px;
  44.         }
  45.         .lds-dual-ring:after {
  46.             content: " ";
  47.             display: block;
  48.             width: 64px;
  49.             height: 64px;
  50.             margin: 8px;
  51.             border-radius: 50%;
  52.             border: 6px solid #fff;
  53.             border-color: #fff transparent #fff transparent;
  54.             animation: lds-dual-ring 1.2s linear infinite;
  55.         }
  56.         @keyframes lds-dual-ring {
  57.             0% {
  58.                 transform: rotate(0deg);
  59.             }
  60.             100% {
  61.                 transform: rotate(360deg);
  62.             }
  63.         }
  64.     </style>
  65.     <body>
  66.         <div class="loader">
  67.             <div class="lds-dual-ring"></div>
  68.         </div>
  69.  
  70.         <h1>Hola!</h1>
  71.         <button onclick="saludar('Uciel')">Saludar</button>
  72.     </body>
  73.  
  74.     <script>
  75.         function saludar(nombre) {
  76.             alert(`Hola ${nombre}!`);
  77.         }
  78.         function showPage(wait, transition) {
  79.             const loader = document.querySelector(".loader");
  80.  
  81.             setTimeout(() => {
  82.                 loader.classList.add("fade-out");
  83.                 setTimeout(() => {
  84.                     loader.remove();
  85.                 }, transition + 1);
  86.             }, wait);
  87.         }
  88.         showPage(2000, 300);
  89.     </script>
  90. </html>
  91.  
  92.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement