Hello developers, today in this blog you'll learn how to create a Responsive Modal Box with Zero JavaScript made only by using HTML & CSS.
Modal Box is also called Dialog Box. This Modal box consists of some text or Dialogues, icons, and the closing button. The modal box appears on the button click. This button click is made to function without using JavaScript Code, i.e. with Zero JavaScript. This function is performed by using a target selector in CSS.
Here, the
target selector has been used to represent a unique element (the target
element) with an id or a class with which it will match. When you click on the
open modal button, the modal box will be shown.
The source
code of this Modal Box is given below, if you want the source code of this program, you can copy it. You can use this Responsive Modal Box code on your projects.
Responsive Modal Box with Zero
JavaScript [Source Codes]
To make this Responsive Modal Box, you need to create two files: an HTML file and a CSS file. First, create an HTML file with the name of index.html and remember, you've to create a file with a .html extension.
CSS provides style to an HTML page. To make the page attractive create a CSS file with the name style.css and remember that you've to create a file with a .css extension.
body{
margin: 0;
background-image: linear-gradient(to right, #43e97b 0%, #38f9d7 100%);
}
.wrapper {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.wrapper a {
display: inline-block;
text-decoration: none;
padding:15px;
background-color: #12192c;
border-radius: 12px;
text-transform: uppercase;
color: #fff;
font-family: 'Roboto', sans-serif;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.wrapper > a:hover{
transform: scale(1.05,1.05);
}
.modal {
visibility: hidden;
opacity: 0;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
transition: all .4s;
}
.modal:target {
visibility: visible;
opacity: 1;
}
.modal__content {
border-radius: 12px;
position: relative;
width: 800px;
max-width: 90%;
background: #12192c;
padding: 1em 2em;
height:300px;
color:#fff;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.modal__content > h1{
color :#38f9d7;
}
.modal__footer {
text-align: right;}
a {
color: #38f9d7;
text-decoration: none;
}
.modal__close {
position: absolute;
top: 10px;
right: 10px;
color: #38f9d7;
text-decoration: none;
font-size: 50px;
}
Thank you for reading our blog. If you face any problem in creating this Responsive Modal Box with Zero JavaScript made only by using HTML & CSS, 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