Materialize css модальное окно

The Modal component in Materialize CSS

The Materialize CSS has a built-in modal component that you may use easily for creating dialog boxes or presenting important content to the visitors where underlying content becomes inactive until the modal window is closed.

The modal can be closed by clicking anywhere outside the modal window or using the close button within the modal. So, you may also use modal for the confirmation messages.

Creating materialize modal is easy and require a few line of codes of HTML and jQuery. In order to modal component work, you need to include the reference to materialize.min.js along with jQuery on the web page.

The following section shows how to create modal using materialize framework with live demo and code snippets.

The example of simple modal

A basic modal contains content and footer. The modal-content class is referred to the main div where you may provide the header and content for the modal.

Use the modal-footer class in another div where close button along with other action buttons can be used. Have a look at the markup, jQuery code and working modal by clicking the link or image below:

Читайте также:  Http www krsk sbit ru quasar php

materialize modal simple

See online demo and code

The markup for the modal:

Источник

Materialize css модальное окно

Use a modal for dialog boxes, confirmation messages, or other content that can be called up. In order for the modal to work you have to add the Modal ID to the link of the trigger. To add a close button, just add the class .modal-close to your button.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

  • Title First Line
    Second Line grade
  • folder Title First Line
    Second Line grade
  • assessment Title First Line
    Second Line grade
  • play_arrow Title First Line
    Second Line grade
  Modal  

Modal Header

A bunch of text

Agree

Modals with Button trigger

If you prefer to use a button to open a modal specify the Modal ID in data-target rather than the href attribute.

Initialization

To open a modal using a trigger:

 document.addEventListener('DOMContentLoaded', function() < var elems = document.querySelectorAll('.modal'); var instances = M.Modal.init(elems, options); >); // Or with jQuery $(document).ready(function()< $('.modal').modal(); >); 

Options

You can customize the behavior of each modal using these options. For example, you can call a custom function to run when a modal is dismissed. To do this, just place your function in the intialization code as shown below.

Name Type Default Description
opacity Number 0.5 Opacity of the modal overlay.
inDuration Number 250 Transition in duration in milliseconds.
outDuration Number 250 Transition out duration in milliseconds.
onOpenStart Function null Callback function called before modal is opened.
onOpenEnd Function null Callback function called after modal is opened.
onCloseStart Function null Callback function called before modal is closed.
onCloseEnd Function null Callback function called after modal is closed.
preventScrolling Boolean true Prevent page from scrolling while modal is open.
dismissible Boolean true Allow modal to be dismissed by keyboard or overlay click.
startingTop String ‘4%’ Starting top offset
endingTop String ‘10%’ Ending top offset

Methods

Because jQuery is no longer a dependency, all the methods are called on the plugin instance. You can get the plugin instance like this:

 var instance = M.Modal.getInstance(elem); /* jQuery Method Calls You can still use the old jQuery plugin method calls. But you won't be able to access instance properties. $('.modal').modal('methodName'); $('.modal').modal('methodName', paramName); */ 
.open();

Источник

Materialize Css Modal Popup

Materialize Css provides predefined classes to create beautiful modals. Materialize Css Modal Popup are used widely in any application so it is important to understand how we can use these popups. Here in this tutorial, we are going to explain how to create modal popup in Materialize css framework. You can also use our online editor to edit and run the code online.

Materialize Css Modal Popup Example

Class modal is used to define the modal, Class modal-content is used to define the content body. Class modal-footer defines the modal footer. Here is an example of Materialize modal popup.-

Example:

Modal 
Tutorialsplane.com

Learn more @ tutorialsplane.com!

Close

Class modal-close is used to add close button in modal.

Materialize Css Modal Popup

Modal class modal-fixed-footer is used to create fixed footer. This class makes footer fixed in case of fixed footer.

Example:

 Modal  
Tutorialsplane.com

Learn everything online.

Close

jQuery Initialization

You must initialize model before using it simply as below-

Open Modal

You can open model using following JavaScript-

Close Model

You can close modal using the below JavaScript-

Options

You can use the following options to customize the default behaviour of modal.

Option Description
dismissible Whether Modal should be unmissable or not.
opacity Adds opacity of overlay background.
inDuration Transition in duration.
outDuration Transition Our duration.
startingTop To add top style attribute.
endingTop To Add ending top style.
ready Callback function when modal is ready.
complete Callback function when modal is closed.

Here is an example of above options-

Example:

$('.modal').modal(< dismissible: true, opacity: .5, inDuration: 300, outDuration: 200, startingTop: '4%', endingTop: '10%', ready: function(modal, trigger) < alert("Ready Callback"); console.log(modal, trigger); >, complete: function() < alert('Closed triggered'); >> );

Источник

Lorem ipsum

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quo, numquam, error, nobis quod minima doloribus laudantium ratione delectus officia maxime iusto esse neque deleniti fugiat.

Paralax

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Expedita, blanditiis, deserunt dolor sit magnam a at voluptatibus officia reiciendis aspernatur.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque, repellat, dignissimos, unde dolores cupiditate nisi saepe doloribus aspernatur at totam iste nobis quaerat vel amet quia ipsa sunt eius quod accusamus reiciendis corrupti pariatur ullam impedit adipisci maxime modi doloremque!

Agree




Файл style.css
/* Изменим цвет меню */
nav background: #803c42;
>

#mypic width: 100px;
height: 80px;
>

/* Изменим высоту паралакс-контейнера. По умолчанию она 500 px */
.parallax-container height: 300px;
>

Источник

Lorem ipsum

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quo, numquam, error, nobis quod minima doloribus laudantium ratione delectus officia maxime iusto esse neque deleniti fugiat.

Paralax

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Expedita, blanditiis, deserunt dolor sit magnam a at voluptatibus officia reiciendis aspernatur.


.prefix — иконка идет перед инпутом,
.validate — для валидации

Иконки: https://materializecss.com/icons.html
—>
account_circle

account_box

lock

mail

Agree



style.css
/* Изменим цвет меню */
nav background: #803c42;
>

#mypic width: 100px;
height: 80px;
>

/* Изменим высоту паралакс-контейнера. По умолчанию она 500 px */
.parallax-container height: 300px;
>

Источник

Оцените статью