JustMinecraftPlayer

Custom Alert in html

Apr 17th, 2022 (edited)
1,133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.81 KB | None | 0 0
  1. <!--Custom Alert Box-->
  2.  
  3. <!--To use custom alert, use the alert() function...-->
  4.  
  5. <!DOCTYPE html>
  6. <html lang="en">
  7. <head>
  8.     <meta charset="UTF-8">
  9.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  10.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11.     <title>Document</title>
  12. </head>
  13. <body>
  14.     <style>
  15.         body{
  16.             background-color: rgb(175, 175, 175);
  17.             font-family: sans-serif;
  18.         }
  19.         #alert-box{
  20.             height: auto;
  21.             width: 15rem;
  22.             background-color: #FFFFFF;
  23.             text-align: center;
  24.             border-radius: .5rem;
  25.             padding: 1rem;
  26.             margin: auto;
  27.             display: none;
  28.         }
  29.         #alert-btn{
  30.             transform: translateX(8.1rem) translateY(-6.3rem);
  31.             height: 1.5rem;
  32.             width: 1.5rem;
  33.             font-weight: bold;
  34.             background-color: #FFAAAA;
  35.             border-style: solid;
  36.             border-radius: .5rem;
  37.             border-color: #FF6666;
  38.         }
  39.         #alert-btn:hover{
  40.             transform: translateX(8.1rem) translateY(-6.3rem) scale(1.1);
  41.         }
  42.     </style>
  43.     <div id="alert-box">
  44.         <h1 id="alert-title">ALERT</h1>
  45.         <button id="alert-btn">&times;</button>
  46.         <h3 id="alert-msg"></h3>
  47.     </div>
  48.     <script>
  49.         alert = (txt) => {
  50.             const id = (input) => {
  51.                 return document.getElementById(input)
  52.             }
  53.  
  54.             id("alert-box").style.display = "block"
  55.             id("alert-msg").innerHTML = txt
  56.             id("alert-btn").onclick = () => {
  57.                 id("alert-box").style.display = "none"
  58.             }
  59.         }
  60.  
  61.         /*
  62.             Example
  63.         */
  64.  
  65.         alert("Alert Test")
  66.     </script>
  67. </body>
  68. </html>
  69.  
Add Comment
Please, Sign In to add comment