Hottest: Get 2K Likes In 1 Day On Facebook Trending: Hide/Show Blogger Widgets | Removing Credits In Template


Contact Us for
A Confidential Discussion

Name E-mail * Message *

X

How to make Modal Window & Popup Boxes with CSS3, Js and Jquery




Creating Modal Dialog Popup Boxes with HTML, CSS3 and Javascript

Modal boxes are quick operable boxes used for Advertisements, Login/Signup Forms, Contact-forms and Notifications. A modal is a utility tool for a webmaster because it can accommodate all the notifications in one place. A modal can build up by using resources such as Jquery, JavaScript, CSS and HTML.
Popup Box open in new window and loads a particular page but in this tutorial we will use modal popup means it will open in a same window. The popup boxes are used to show something in a new box or window but in this tutorial we will use these dialog boxes for displaying notifications, advertisements and various types of forms.

Demo | A Whole Modal Box Plugin Library


We are going to use CSS3’s target-events, transitions, opacity and overlay adjustment. In Javascript we will use visibility and opacity attributes. In Jquery we use .animate method.

You can download the demos and Modal Box Plugin Library from here.
Click Here to View Demo

Creating Modal Dialog Popup Boxes with HTML, CSS3 and Javascript


This Modal Box Plugins Library contains 8 types of modal and popup windows. Some of them are build up by using Jquery and 2 of the modal are made up of Javascript. It also contains a Simple modal made up with Pure CSS using the Target: Event.

Adding Styles and Animations Link


Before creating a modal box you need to paste the link of CSS Files of modal box and you will also had to paste the link of Javascript/Jquery resources.
Now, let’s go to blogger and edit the template.
Search for <head> and paste the following codes below it.


<link href=”https://dl.dropboxusercontent.com/s/u2spykwmbvk91x3/dialog-box.css”  type=”text/css” />
<script src=”https://dl.dropboxusercontent.com/s/zbft9v4qk4u3m72/dialog-box.js”   type=”text/javascript” ></script>

After applying these codes you will be able to use our modal box.

Adding HTML Structure


Now, it’s time to add the main HTML structure to your modal box, now we are breaking this tutorial in 3 parts and we will separately discuss about three modal boxes made up with CSS, Jquery And Js.


Creating a Modal with CSS


In this modal box we will use CSS styling and HTML structure only, as we had linked the CSS file above, so we had to create only a HTML structure. We are using a div tag to hold the content in the modal. We are also giving a close button inside the div tag to close the modal.
The HTML structure will look like below-

<div class='modalDialog' id='openmodal'>
<div>
<a class='close' href='#close' title='Close'>x</a>
Your Content Here</div>
</div>

We had allotted the id openmodal to our modal box because it is simple to use and to open the modal box we will use this id as a button of modal. It will look like this-
 We will use the ID just as a hook for opening our modal box and to call it we will use this markup.
To open our modal box we will use this syntax-

<a href=”#openmodal”>Open the modal</a>

Now our modal will look like this picture below-

Creating Modal Dialog Popup Boxes with HTML, CSS3 and Javascript


Creating Modals with Jquery-


To create a modal with Jquery we need some Jquery elements and combine them at one place. In this modal box first we need to link up the Jquery Files in order to use their functions.
Search for <head> and paste this script below it-

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js”   type=”text/javascript”></script>

Now as I had already told you that we had placed the Jquery files above, now we need to create only HTML structure. In this Jquery modal box we are using only animation like .animate function in which we send our modal box to different location when it is opened or closed.
Let’s create a HTML structure of a Jquery modal box.


<div class="layout" id="layout" style="display:none;"></div>
<div class="dialog-box" id="dialog-box">
 <a class="dialog-boxclose" id="dialog-boxclose" title="Close"></a>
YOUR CONTENT HERE</div>

In this Modal dialog box we used the .animate property. When the link of modal is clicked it opens the modal box (the modal comes from upward and visible to us).  We also added a close button and when it is clicked modal will go up and hide.
Now, it’s time to create a link to open the modal box. The link will be like this below-

<a href="#" id="activator">Click This Button to open the modal</a>

Now our modal will look like this image-

Creating Modal Dialog Popup Boxes with HTML, CSS3 and Javascript


Creating a Modal with Pure JavaScript


In this section we will create a modal only with Javascript and CSS3. As we told you that we had already linked the javascript and css files then we will create HTML structure only. In this modal box we had used javascript function of visibility it is written as style.visible or we had used style.hidden for hiding the modal box. So let’s create a modal box using javascript and CSS3.
The HTML structure of Modal JS will be like this-

<div id="overlayer">
     <div>
          Your Content Here
<a onclick='overlay()' style="cursor:pointer;" id="overlayerclose">X</a>
     </div>
</div>

Now your modal box is ready to use it. Let’s create a button to open the modal,

<a onclick="overlay()" style="cursor:pointer">Click here to open the modal</a>

This modal will look like-
Creating Modal Dialog Popup Boxes with HTML, CSS3 and Javascript


When to use a Modal Box


Modal box can be used in many ways. After researching on this topic we had concluded that modal boxes can be used for following purposes which includes Promotions, Advertisements, Contact Form, Email Subscription forms, Notification and Login/Register forms.


Login/Register Forms-


Modal boxes are particularly useful when used for login and registration forms. It creates such a streamlined experience for the user, and can really make an impression on your visitors. It displays on the top and it is useful for login forms. The below image  is a live example of Login/Resister form.

Creating Modal Dialog Popup Boxes with HTML, CSS3 and Javascript Login/register forms can be used in Modal boxes


E-Mail Subscription Forms-

Yes! You can use these modal boxes for building your email through them. In case, if you don’t have any space to add your email form on that page then you can use these modals as a popup window they doesn’t take space on your page and they can be opened slightly. Modal Boxes are the best way to build your email-list and you can configure it according to you. By using Modal popups you can attract your customers in first sight on your page because “First impression is the last impression”.

Creating Modal Dialog Popup Boxes with HTML, CSS3 and Javascript Email-Subscribe Form can be used in Modal boxes



Displaying Images and Videos

There is also a great benefit of using modal popups that you can use them to display your pictures. If you add images and videos on modal box then it will called a Lightbox. It allows for the user to view the content of your website without leaving the webpage.

Creating Modal Dialog Popup Boxes with HTML, CSS3 and Javascript Images/Videos can be displayed on modal windows


Using Modals as a Contact-Form

You can also use modal boxes for contact form. Commonly we display contact-forms in sidebars, footers and even sometimes in pages also. But it is a great idea that you can use the modals as a contact form. Hence it portable and can be opened on any page. This image below is a great example to use modals as a contact-form.

Creating Modal Dialog Popup Boxes with HTML, CSS3 and Javascript Contact-form can be used in modal boxes and popup windows and dialog boxes


Conclusion

There you have learned a lot of things, now you can create modals on your own using CSS3, Javascript and Jquery. You can use these modal boxes for login/registration forms, advertisements, notifications and much more.  You’ve also learned why we are using only CSS on modal #1, using Jquery on Modal #2 and using javascript on modal #3, and seen some examples of how sites use modal boxes and how you can also add them to your site or designs.

Are you thinking that you can add some more stuff on these modals or you can create it by any other method? Let us know by leaving your comments below.

24 comments

Click here for comments
May 25, 2015 at 8:55 AM ×

hmmm... its interesting well you can provide a source file for downloading

Reply
avatar
Justin Mere
admin
May 25, 2015 at 9:12 AM ×

great examples i had ever seen but i think that you can also add slideshows to your modal boxes

Reply
avatar
May 25, 2015 at 10:05 AM ×

yes justin mere i had added the slideshow to my modal.
but @admin i got a problem that the slideshow wrap doesn't fit on my modal
so what should i do next??? Plzzz Its Urgent

Reply
avatar
Larry Minns
admin
May 25, 2015 at 11:09 AM ×

Your dialog boxes are cool but i can't understand y u r calling them modals??

Reply
avatar
Harshit Gaur
admin
May 25, 2015 at 11:11 AM ×

Yes , i will try to upload a source file and link it up to this post very soon,
@peter thanks for your suggestion

Reply
avatar
Harshit Gaur
admin
May 25, 2015 at 11:13 AM ×

@justin
yes you can add slideshows, but u need good quality of slideshows see this tutorial-
http://www.mybloggertricks.com/2010/12/how-to-create-stunning-slideshows-in.html

Reply
avatar
Harshit Gaur
admin
May 25, 2015 at 11:16 AM ×

hey @prashant-
see that MBT tutorial or you can see mine- click on the link below-
http://hackintricks4u.blogspot.in/2014/12/how-to-create-stunning-image-slide-show.html

you had to place your slideshow wrapper between the div tags of modal

Reply
avatar
Harshit Gaur
admin
May 29, 2015 at 8:13 AM ×

Modals are good and they are working fine on my website but i want to know that how to add a contact form in modal window

Reply
avatar
Unknown
admin
May 30, 2015 at 1:46 AM ×

Nice article.Being finished Software Engineering and working as a research paper writer in one of the custom research paper website i felt bad on myself for these days. But,on seeing this blog,i felt happy and i had a thought of sharing my views, thinking and ideas about various topics which all i had studied in my software engineering.

Reply
avatar
Harshit Gaur
admin
May 30, 2015 at 4:18 AM ×

thanks for your feedback.

Reply
avatar
Unknown
admin
December 23, 2015 at 1:54 AM ×

Thanks for posting such wonderful and most useful article for myself because being working as a web designer trainee in one of the leading online custom research writing website, the above article will be really very much helpful in my job to get myself to know about the various new updates and get myself to be knowledge enlargement in the field of web designing. I have been looking forward to read such more articles regarding various .

Reply
avatar
afssac
admin
August 14, 2016 at 2:02 AM ×

Thank you for sharing knowledge and thanks for your nice efforts

Reply
avatar
nasihnetwork
admin
August 18, 2016 at 1:45 PM ×

Thank you for sharing nice information . I like to know more about what is new and i think that we must always learn from each other

Reply
avatar
admin
admin
November 29, 2016 at 3:08 PM × This comment has been removed by the author.
avatar
sai
admin
September 10, 2017 at 10:58 PM ×

I appreciate any good efforts

Reply
avatar
PLUGGERS
admin
October 15, 2019 at 6:00 PM ×

ARE YOU A VICTIM OF FALSE HACKERS & BANK LOAN SCAM⁉️

We have been having recent complains from individuals about how they lost money 💵 to SPAMMERS who call themselves HACKERS or BANK LOAN OFFERS. They are all over the internet sharing false testimonies. Please do not fall for their lies for this is just a way to LURE you to them.

They say lies in the likes of such-:
▪️Bitcoin Auctioning ▪️Western Union Hack
▪️Blank Credit Card ▪️Clearing Criminal Records
▪️Loan Offers. ▪️Bank Account Loading
▪️Changing University Grades & so on.
These are all lies and you shouldn’t fall for them.

🏵GLOBAL PLUGGERS🏵 is here to help you Recover all your Money 💵 that you have been Ripped of.
WHO ARE GLOBAL PLUGGERS⁉️
We are a group of Computer💻 Experts who are memebers of the “HACKERONE” Forum. We have dedicated ourselves to help Victims of these SCAM(s) recover all the Money that has been taken falsely from them.

If you have been a victim of thes Thieves, then you need to contact us as soon as possible so you can get your money back.
Email-: globalpluggers@gmail.com
No. +1 (808) 600 0773 ( Number also available on WhatsApp)

Note:
Please know that we do not charge you for Fund Recovery Service, Our Funds Recovery Service is to help and so it’s Free.

We also provide Legit Hacking Services such as-:
🔸Phone Hacking/Cloning
🔸Email Hacking & Password Recovery
🔸Social Media Hacking & Passowrd Recovery
🔸Deleted Files Recovery 🔸Mobil Tracking
🔸Virus detection & Elimination.

Contact-:
Email globalpluggers@gmail.com
No. +1 (808) 600 0773 (number also available on WhatsApp)








Reply
avatar
March 25, 2020 at 10:16 PM ×

Have you heard about programmed ATM card? email: (williamshackers@hotmail.com) or WhatsApp +27730051607 for enquiring on how to get the ATM programmed card.
We have special cash loaded programmed ATM card of $5000, $10000, $15000, $20000 and any amount your choice you need for you to buy your dream car, house and to start up your own business. Our ATM card can be used to withdraw cash at any ATM or swipe, stores and POS. Our card has daily withdrawal limit depending card balance you order. Contact us via Email if you need a card email: (williamshackers@hotmail.com) or WhatsApp +27730051607.

Reply
avatar
May 5, 2020 at 2:17 PM ×

I Want to use this medium in appreciating cyber golden hacker , after being ripped off my money,he helped me find my cheating lover he helped me hack her WHATSAPP, GMAIL and kik and i got to know that he was cheating on me, in less than 24 hours he helped me out with everything, cybergoldenhacker is trust worthy and affordable contact him on: cybergoldenhacker at gmail dot com

Reply
avatar
September 1, 2020 at 5:14 AM ×

If you are in need of financial Help, don't hesitate to place order for deserve Programmed card that can withdraw any amount limit you want. Deserve Card are very transparent and easy to deal with. You can Purchase Deserve card that can withdraw up to $50,000 to $100,000 limit without being detected because of the programming of the card.  I'm extremely grateful to them for being honest with their words and delivering the card to me. This is the third day of receiving the card and i have withdraw $9,500 from the Deserve Programmed Card. I tried purchasing the card previously from someone else, but it never arrived until i tried skylink technology for those in need of more money, you can also contact them. you can place order for the card Via whatsapp/telegram +1(213)785-1553  or their E-mail: skylinktechnes@yahoo.com 

Reply
avatar
September 1, 2020 at 7:31 AM ×

Do you need to increase your credit score?
Do you intend to upgrade your school grade?
Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
Do you need any information concerning any database.
Do you need to retrieve deleted files?
Do you need to clear your criminal records or DMV?
Do you want to remove any site or link from any blog?
you should contact this hacker, he is reliable and good at the hack jobs..
contact : cybergoldenhacker at gmail dot com

Reply
avatar
December 7, 2020 at 7:44 PM ×

Do you need to increase your credit score?
Do you intend to upgrade your school grade?
Do you want to hack your cheating spouse Email, whatsapp, Facebook, instagram or any social network?
Do you need any information concerning any database.
Do you need to retrieve deleted files?
Do you need to clear your criminal records or DMV?
Do you want to remove any site or link from any blog?
you should contact this hacker, he is reliable and good at the hack jobs..
contact : cybergoldenhacker at gmail dot com

Reply
avatar
March 11, 2022 at 11:22 AM ×

https://blogansetv.blogspot.com/2022/03/Number-daily-visits.html

Reply
avatar