How To Create Bootstrap 3 Modal Window

A modal window is a popup window like lightbox, there is a three size modal window in bootstrap 3, today we will going to discuss about Bootstrap 3 Modal Window.

How to make bootstrap 3 modal window

to make a modal window need to take a trigger in which on click the modal window will open or you can write some javascript code to make the modal window open on load.

Make the modal window trigger

To make a modal window trigger take a button or anchor tag (the element which is clickable) and use there data-toggle="modal" and data-target="#myModal" , Here myModal is the id of the model window.

Example:


Now make the popup portion.

To make the model first take a div with the id which is called by the trigger, and use the class name .modal and .fade and role="dialog"

Model Dialog:

Inside the div with the class name .modal take another div with the class name .modal-dialog

Model Content:

The Inside the div modal-dialog take a div with the class name .modal-content to make the container of the model

Model Header:

Inside the model, content takes a div with the class name .modal-header to make a model header and you can use heading paragraph and closing button etc insider the modal header

Modal Body

To create a modal body you can use the class name .modal-body inside the modal content div.

Modal Footer

To create modal footer use class name .modal-footer inside the modal container.

Modal Closing:

The modal window will be closed if you click outside of the modal window, but you can create a button to make the modal close on click the button and to make that use the class name .close and and data-dismiss="modal" to the closing button

Example:






Size of Bootstrap 3 Modal

Bootstrap 3 provides us 3 different sizes modal window and they are as described be

Small Modal Size:

To make a small modal size use class name .modal-sm with the .modal-dialog class name

Share The Post On -

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.