How to use modal boxes in Bootstrap? A brief analysis of the usage of Modal components

青灯夜游
Release: 2021-12-06 19:00:39
forward
2239 people have browsed it

How to use modal box in

Bootstrap? The following article will introduce to you the usage of the Modal component of the Bootstrap5 modal pop-up box. I hope it will be helpful to you!

How to use modal boxes in Bootstrap? A brief analysis of the usage of Modal components

1 How the Bootstrap5 modal pop-up box works

Use Bootstrap's JavaScript mode plug-in to add dialog boxes to the site for light boxes, user notifications, or Fully customizable content. [Related recommendations: "bootstrap Tutorial"]

  • The interactive window is built with HTML, CSS and JavaScript. They sit above any other content in the file and remove scrolling from the body so that the interactive viewport's content scrolls.
  • Clicking the "backdrop" of the interactive window will automatically close the interactive window.
  • Bootstrap only supports one interactive window at a time. Nested interactive windows are not supported because we consider nested interactive windows to be a poor user experience.
  • The interactive window uses position: fixed, which is a bit special in rendering and presentation. Place your interactive viewport HTML at the top level whenever possible to avoid potential interference from other elements. You may run into problems when adding a .modal inside another fixed element.
  • Because of position: fixed, there are some additional instructions for using interactive windows on mobile devices.
  • According to the way HTML5 defines semantics, the autofocus HTML attribute has no impact on Bootstrap interactive windows. To achieve the same effect, use some custom JavaScript: the autofocus HTML attribute

2 Full example

2.1 Full example

Toggle by clicking the button below Dynamic window rendering. It will slide down from the top of the page and fade in. Click the close button or click the background area to close the pop-up window.

        模态框 
Copy after login

How to use modal boxes in Bootstrap? A brief analysis of the usage of Modal components

2.2 Static background

When the background is set to static, the interactive window will not be closed by clicking on the background. Just adddata-bs-backdrop="static" data-bs-keyboard="false"to

Copy after login

How to use modal boxes in Bootstrap? A brief analysis of the usage of Modal components

For more knowledge about bootstrap, please visit:bootstrap basic tutorial! !

The above is the detailed content of How to use modal boxes in Bootstrap? A brief analysis of the usage of Modal components. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:juejin.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!