Учебник по Bootstrap 4

BS4 ГЛАВНАЯ BS4 Начать Контейнеры BS4 Базовая сетка BS4 Типография BS4 Цвета BS4 Таблицы BS4 Изображения BS4 BS4 Джамботрон Оповещения BS4 Кнопки БС4 Группы кнопок BS4 Значки BS4 Индикаторы выполнения BS4 Спиннеры BS4 BS4 Пагинация Группы списков BS4 Карты BS4 Выпадающие списки BS4 Свернуть BS4 BS4 Навс BS4 навигационная панель БС4 Формы Входы БС4 Входные группы BS4 Пользовательские формы BS4 BS4 Карусель BS4 модальный Подсказка BS4 BS4 всплывающее окно BS4 Тост BS4 прокрутки Утилиты BS4 BS4 Flex Иконки BS4 Медиа-объекты BS4 Фильтры BS4

Bootstrap 4 Сетка

Сетевая система BS4 BS4 Сложенный/горизонтальный BS4 Сетка XSмаленький BS4 Малая сетка Сетка BS4 средняя BS4 Сетка большая BS4 Сетка XLarge Примеры сетки BS4

Начальная загрузка 4 Другое

Базовый шаблон BS4 Упражнения BS4 Викторина БС4

Начальная загрузка 4 Ссылка

Все классы JS-оповещение JS-кнопка JS Карусель Свернуть JS Выпадающий список JS Модальный JS JS всплывающее окно JS прокрутка Вкладка JS JS тосты JS-подсказка


Bootstrap JS модальный


Модальные классы CSS

Чтобы узнать больше о модальных окнах, прочитайте наш учебник по модальным окнам Bootstrap .

Class Description Example
.modal Creates a modal
.modal-content Styles the modal properly with border, background-color, etc. Use this class to add the modal's header, body, and footer
.modal-dialog-centered Centers the modal vertically and horizontally within the page
.modal-dialog-scrollable Adds a scrollbar inside the modal
.modal-header Defines the style for the header of the modal
.modal-body Defines the style for the body of the modal
.modal-footer Defines the style for the footer in the modal. Note: This area is right-aligned by default. To change this, add the justify-content-start or justify-content-center together with the .modal-footer class
.modal-sm Specifies a small modal
.modal-lg Specifies a large modal
.fade Adds an animation/transition effect which fades the modal in and out

Запуск модального окна через атрибуты data-*

Добавьте data-toggle="modal"и data-target="#modalID"к любому элементу.

Примечание. Для <a>элементов опустите data-targetи используйте href="#modalID"вместо него:

Пример

<!-- Buttons -->
<button type="button" data-toggle="modal" data-target="#myModal">Open Modal</button>

<!-- Links -->
<a data-toggle="modal" href="#myModal">Open Modal</a>

<!-- Other elements -->
<p data-toggle="modal" data-target="#myModal">Open Modal</p>

Триггер через JavaScript

Включить вручную с помощью:

Пример

$("#myModal").modal()

Модальные параметры

Параметры можно передавать через атрибуты данных или JavaScript. Для атрибутов данных добавьте имя опции к data-, как в data-backdrop="".

Name Type Default Description Try it
backdrop boolean or the string "static" true Specifies whether the modal should have a dark overlay:

  • true - dark overlay
  • false - no overlay (transparent)

If you specify the value "static", it is not possible to close the modal when clicking outside of it

keyboard boolean true Specifies whether the modal can be closed with the escape key (Esc):

  • true - the modal can be closed with Esc
  • false - the modal cannot be closed with Esc
show boolean true Specifies whether to show the modal when initialized

Модальные методы

В следующей таблице перечислены все доступные модальные методы.

Method Description Try it
.modal(options) Activates the content as a modal. See options above for valid values
.modal("toggle") Toggles the modal
.modal("show") Opens the modal
.modal("hide") Hides the modal

Модальные события

В следующей таблице перечислены все доступные модальные события.

Event Description Try it
show.bs.modal Occurs when the modal is about to be shown
shown.bs.modal Occurs when the modal is fully shown (after CSS transitions have completed)
hide.bs.modal Occurs when the modal is about to be hidden
hidden.bs.modal Occurs when the modal is fully hidden (after CSS transitions have completed)