Hello developers, today in this blog, you'll learn to create a Popup Warning Notification using HTML, CSS & JavaScript.
A Warning Notification box, sometimes also called a message box. It is a small window that pops up on your screen to warn you that your system is about to perform some operation with potentially damaging consequences.
In this blog (Popup Warning Notification) on the webpage, there is a button at the center of the webpage. When you hover the button the background color of the button changes, this hover effect is made by using the CSS hover effect. When you click on the button, the warning notification will pop at the right top corner of the webpage. This notification hides automatically after a few seconds and there is also a cross sign button to hide that notification.
The source code of this Popup Warning Notification is given below, if you want the source code of this program, you can copy it. You can use this Popup Warning Notification with your creativity and take this project to the next level.
Popup Warning Notification [Source Code]
To make this website, you would like to make three files: an HTML file, a CSS file & a JavaScript file. First, create an HTML file with the name of index.html and remember, you have to create a file with a .html extension.
@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap');
*{
margin: 0;
padding: 0;
user-select: none;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
html,body{
height: 100%;
background-color: #2d333f;
}
body{
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
button{
padding: 8px 16px;
font-size: 25px;
font-weight: 500;
border-radius: 4px;
border: none;
outline: none;
background: #f8f3d6;
color: #967132;
letter-spacing: 1px;
cursor: pointer;
}
button:hover{
background: #dcd4a2;
}
.alert{
background: #f8f3d6;
color: #967132;
padding: 25px 50px;
min-width: 420px;
position: absolute;
right: 0;
top: 10px;
border-radius: 5px;
border-left: 8px solid #967132;
overflow: hidden;
opacity: 0;
pointer-events: none;
}
.alert.showAlert{
opacity: 1;
pointer-events: auto;
}
.alert.show{
animation: show_slide 1s ease forwards;
}
@keyframes show_slide {
0%{
transform: translateX(100%);
}
40%{
transform: translateX(-10%);
}
80%{
transform: translateX(0%);
}
100%{
transform: translateX(-10px);
}
}
.alert.hide{
animation: hide_slide 1s ease forwards;
}
@keyframes hide_slide {
0%{
transform: translateX(-10px);
}
40%{
transform: translateX(0%);
}
80%{
transform: translateX(-10%);
}
100%{
transform: translateX(100%);
}
}
.alert .fa-exclamation-triangle{
position: absolute;
left: 20px;
top: 50%;
transform: translateY(-50%);
color: #967132;
font-size: 30px;
}
.alert .msg{
padding: 0 20px;
font-size: 18px;
color: #967132;
}
.alert .close-btn{
position: absolute;
right: 0px;
top: 50%;
transform: translateY(-50%);
background: #967132;
padding: 20px 18px;
cursor: pointer;
}
.alert .close-btn:hover{
background: #dcd4a2;
}
.alert .close-btn .fas{
color: #dcd4a2;
font-size: 22px;
line-height: 40px;
}
.credit{
text-align: center;
color: #fff;
margin-top: 30px;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
.credit a{
text-decoration: none;
color: #f8f3d6;
font-weight: bold;
}
$('button').click(function(){
$('.alert').addClass("show");
$('.alert').removeClass("hide");
$('.alert').addClass("showAlert");
setTimeout(function(){
$('.alert').removeClass("show");
$('.alert').addClass("hide");
},5000);
});
$('.close-btn').click(function(){
$('.alert').removeClass("show");
$('.alert').addClass("hide");
});
Thank you for reading our blog. If you face any problem creating this Popup Warning Notification using HTML, CSS & JavaScript, then contact us or comment us. We'll try to provide a solution to your problem as soon as possible.
إرسال تعليق
Thank you
Learning robo team