Modal

A classic modal, in which you can include any content you want.

github.com/tobento-ch/css-modal

Import Files

Css

Basic Usage

The basic modal structure is:

The minimal modal structure is:

To activate the modal, just add the .active class on the .modal container. The provided modal.js file implements the logic to open, close and animate the modals.

Sizing

By default, the modal has full width size. You may apply one of the following sizes:

Resize the window to see the full modal view.

The body gets scrollable if you have a lot of content.

Positions

By default, the modal is horizontal and vertical centered. You may combine the horizontal and vertical classes.

Modal Horizontal Alignment:

Modal Vertical Alignment:

Animations

Available Animations:

JavaScript

Register

The Html markup for registering a modal is:

Open modal

You may add the modal-close class to any tag for closing the modal:

Open modal

Options:

Open modal
Option Value Description
"scroll" "visible" Disables scroll, keeping scrollbar visible.
"scroll" "hidden", default Disables scroll, keeping scrollbar hidden.
"scroll" null Without disable scroll.
"closeTriggers" ".modal-background, .modal-close", default The trigger classes to close the modal.

Methods

You may import the modals module and use its methods:

Events

Event Description
open This event is fired before the modal is opened.
opened This event is fired after the modal is opened.
close This event is fired before the modal is closed.
closed This event is fired after the modal is closed.