The content on this website, including videos and code examples, is for educational purposes only. All demonstrations and designs are fictional and created to illustrate coding techniques. Any resemblance to existing websites or brands is purely coincidental.
The creators and administrators of this website do not claim ownership or affiliation with any existing websites or companies. Users are encouraged to use the information responsibly for learning purposes. Liability for any misuse of the content provided is not accepted.
Below is the html code for this video.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="index.css" />
<script type="text/javascript" src="index.js"></script>
<title>Custom Alert</title>
</head>
<body>
<div id="dialogoverlay"></div>
<div id="dialogbox">
<div>
<div id="dialogboxhead" class="glow"></div>
<div id="dialogboxbody"></div>
<div id="dialogboxfoot"></div>
</div>
</div>
<div class="btn-container">
<button
class="btn-alert"
onclick="Alert.render('Title','Message Body','Footer')"
>
Custom Alert Button
</button>
<button class="btn-alert" onclick="Alert.render('','','')">
Blank Alert Button
</button>
</div>
</body>
</html>
Below is the css code for this video.
index.css
html,
body {
margin: 0px;
padding: 0px;
height: 100%;
width: 100%;
background-image: linear-gradient(#2193b0, #6dd5ed);
}
h4 {
display: block;
font-size: 1.5em;
font-weight: bold;
margin-block-start: 0.1em;
margin-block-end: 0.1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}
#dialogoverlay {
display: none;
opacity: 0.25;
position: fixed;
background: #292b2c;
width: 100%;
z-index: 10;
}
#dialogbox {
display: none;
position: fixed;
width: 50%;
z-index: 10;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#dialogbox > div > #dialogboxhead {
font-size: 24px;
padding: 20px;
text-align: center;
color: #000000;
letter-spacing: 5px;
background-image: linear-gradient(#ee9ca7, #ffdde1);
border: 1px solid #ffffff;
}
#dialogbox > div > #dialogboxbody {
font-size: 24px;
padding: 20px;
text-align: center;
color: #000000;
letter-spacing: 1px;
background-image: linear-gradient(#de6262, #ffb88c);
border-left: 1px solid #ffffff;
border-right: 1px solid #ffffff;
}
#dialogbox > div > #dialogboxfoot {
font-size: 24px;
padding: 20px;
text-align: center;
color: #000000;
letter-spacing: 2px;
cursor: pointer;
background-image: linear-gradient(#ee9ca7, #ffdde1);
border: 1px solid #ffffff;
}
.btn-container {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.btn-alert {
display: inline-block;
padding: 15px 30px;
margin: 10px;
font-size: 25px;
text-align: center;
cursor: pointer;
outline: none;
color: #ffffff;
text-transform: capitalize;
background-image: linear-gradient(#bdc3c7, #2c3e50);
border: none;
border-radius: 15px;
text-decoration: none;
font-family: Arial, Helvetica, sans-serif;
transition: 0.25s ease-in-out;
box-shadow: 0 15px 20px -10px #adadad;
}
.btn-alert:hover {
box-shadow: 0 35px 20px -20px #777777;
transform: translateY(-10%);
}
Below is the javascript code for this video.
index.js
function CustomAlert() {
this.render = function (head, body, foot) {
var dialogoverlay = document.getElementById("dialogoverlay");
var dialogbox = document.getElementById("dialogbox");
var dialogboxhead = document.getElementById("dialogboxhead");
var dialogboxbody = document.getElementById("dialogboxbody");
var dialogboxfoot = document.getElementById("dialogboxfoot");
dialogoverlay.style.display = "block";
dialogbox.style.display = "block";
head === "" && (head = "Alert Title");
body === "" && (body = "Alert Message Body");
foot === "" && (foot = "Alert Footer");
dialogboxhead.innerHTML = "<h4>" + head + "</h4>";
dialogboxbody.innerHTML = body;
dialogboxfoot.innerHTML =
"<div onclick='Alert.ok()'><strong>" + foot + "</strong></div>";
};
this.ok = function () {
document.getElementById("dialogbox").style.display = "none";
document.getElementById("dialogoverlay").style.display = "none";
};
}
var Alert = new CustomAlert();
Thanks for visiting