Hello readers, Today in this blog you'll learn how to create a Dialog or Modal Box using HTML CSS & Javascript. Previously I have shared a Fixed Sidebar Social Media Share Widget using HTML & CSS, now it's time to create a Modal Box using HTML CSS Javascript or JQuery.
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 understand what I am saying. You can watch a full video tutorial on this program (Custom Modal Box).
Video Tutorial of Dialog Box or Modal Box using HTML CSS & Javascript
I hope you understood the basic concepts and codes of this Modal Box. As you have seen in the video I used jQuery to show and hide the Modal Box. I think it will help beginners to understand the actual concepts behind creating a modal box.
If you like this program (Custom Modal Box) and want to get source codes. You can easily get the source codes of this program. To get the source codes you just need to scroll down.
If you like this program (Custom Modal Box) and want to get source codes. You can easily get the source codes of this program. To get the source codes you just need to scroll down.
Modal Box or Dialog Box using Javascript [Source Codes]
As always, before sharing the codes of this program (Custom Modal Box). Let's talk about the main tags and codes of this program. As you have seen in the video this is the jQuery program, which means jQuery is used to create this modal box. In the video, you can see I created a div tag with the class name "modal" and placed all other tags inside it. Then I created one 'X' icon and one close button. This button is for hiding the modal box, it will appear on button click using jQuery.
I used font-awesome to show the camera icon and the 'X' button. Now using CSS I have placed the element at middle position and used CSS @import for getting a google font. Now put some values like the color on hover.
After created this Modal Box, I gave the modal opacity: 0; and bottom: -100%; to hide this modal. And, using jQuery I coded this modal when a user clicks on the show button, the modal box will be shown.
To create this program (Custom Modal Box). First, you need to create two Files one HTML File and another one is CSS File. After creating these files just paste these following codes in your file.
I used font-awesome to show the camera icon and the 'X' button. Now using CSS I have placed the element at middle position and used CSS @import for getting a google font. Now put some values like the color on hover.
After created this Modal Box, I gave the modal opacity: 0; and bottom: -100%; to hide this modal. And, using jQuery I coded this modal when a user clicks on the show button, the modal box will be shown.
To create this program (Custom Modal Box). First, you need to create two Files one HTML File and another one is CSS File. After creating these files just paste these following codes in your file.
HTML FILE:
CSS FILE:

Hello, great work! can i use it on my website?
ReplyDeletePost a Comment
We welcome relevant and respectful comments. Off-topic or spam comments may be removed.