M/s VIKASH TECH - We Write Imaginations to Codes..!!

Custom Modal Box using HTML CSS & Javascript

Hello readers, Today in this blog you’ll learn how to create a Dialog or Modal Box using HTML CSS & Javascript.
Maybe you have seen many types of modal boxes on many websites, Some peoples describe this is as a Dialog box also. For example, when we log out from Facebook there a confirmation appears to are you sure, that’s called dialog modal box.
As you can see in the image, this is a Dialog or Modal Box. In the image, there are some texts, icons, and one close button. The modal box appears on button click that’s a function handled by jQuery. When you click on the show modal button the modal box will be shown from the right bottom side.

If you’re feeling difficulty to understanding what I’m saying then you can Try the code below to check the output yourself.Still facing issues? Feel free to mail us your queries on info@vikashtech.com


<!DOCTYPE html>
<!-- Created By praveen kumar -->
<html lang="en" dir="ltr">
    <meta charset="utf-8">
    <title>Custom Modal Box | VikashTech</title>
    <link rel="stylesheet" href="blog.css">
    <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
    <script src="https://kit.fontawesome.com/a076d05399.js"></script>
    <div class="show-btn">
      <button>Show Modal</button>
<div class="modal">
      <div class="top-content">
        <div class="left-text">
Modal Box</div>
<span class="close-icon"><i class="fas fa-times"></i></span>
        <div class="fas fa-camera-retro">
<div class="bottom-content">
        <div class="text">
Custom Modal Box</div>
Create a simple modal box using html and css only.</p>
<div class="close-btn">
          <button>Close Modal</button>


@import url('https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap');
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins',sans-serif;
  background: #f2f2f2;
  text-align: center;
  overflow: hidden;
  position: absolute;
  top: 50%;
  left: 50%;
  user-select: none;
  transform: translate(-50%, -50%);
  pointer-events: none;
  position: absolute;
  right: 0;
  opacity: 0;
  bottom: -100%;
  width: 360px;
  transition: bottom 0.4s, opacity 0.4s;
  box-shadow: 0px 0px 15px rgba(0,0,0,0.3);
  bottom: 0;
  opacity: 1;
.modal .top-content{
  background: #34495e;
  width: 100%;
  padding: 0 0 30px 0;
.top-content .left-text{
  text-align: left;
  padding: 10px 15px;
  font-size: 18px;
  color: #f2f2f2;
  font-weight: 500;
  user-select: none;
.top-content .close-icon{
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 23px;
  color: silver;
  cursor: pointer;
  color: #b6b6b6;
.top-content .fa-camera-retro{
  font-size: 80px;
  color: #f2f2f2;
.modal .bottom-content{
  background: white;
  width: 100%;
  padding: 15px 20px;
.bottom-content .text{
  font-size: 28px;
  font-weight: 600;
  color: #34495e;
.bottom-content p{
  font-size: 18px;
  line-height: 27px;
  color: grey;
.bottom-content .close-btn{
  padding: 15px 0;
.show-btn button,
.close-btn button{
  padding: 9px 13px;
  background: #27ae60;
  border: none;
  outline: none;
  font-size: 18px;
  text-transform: uppercase;
  border-radius: 3px;
  color: #f2f2f2;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
.show-btn button{
  padding: 12px 15px;
.show-btn button:hover,
.close-btn button:hover{
  background: #26a65b;
Category :


No comments found.



Latest Posts

Templates - In Flask

Templates are the structure of a website. Here in Python Flask. templates are treated as the views, which means these…

Static Files - Flask

When you work for web development, you will need to use some files for javascript or CSS, here in FLASK…

Variables in Flask

In Flask, a variable is created using tags inside route() function. To create a variable you just need to put…

Flask - Binding URL

First thing that comes to mind when we hear binding is - I guess - BOOKBINDING / PAPER BINDING. Well,…