Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Modal Box in Bootstrap

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use the modal box in Bootstrap, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

Working principle of 1 Bootstrap5 modal bullet frame

Use Bootstrap's JavaScript mode plug-in to add dialogs to the site for light boxes, user notifications, or fully customized content.

Interactive windows are built with HTML, CSS, and JavaScript. They are on top of anything else in the file and remove scrolling from the body so that the contents of the interactive window scroll.

Clicking "backdrop" in the interactive window will automatically close the interactive window.

Bootstrap supports only one interactive window at a time. Nested interactive windows are not supported because we think that the user experience of nested interactive windows is not good.

Interactive windows use position: fixed, which is a bit special in rendering. Place your interactive window HTML at the top level as much as possible to avoid potential interference from other elements. You may encounter problems when you add a .modal to another fixed element.

Because of position: fixed, there are some additional instructions for using interactive windows on mobile devices.

Depending on how HTML5 defines semantics, the autofocus HTML attribute has no effect on the Bootstrap interactive window. To achieve the same effect, use some custom JavaScript:the autofocus HTML attribute

2 complete example 2.1 complete example

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

Modal box deletion content confirmation prompt can not be restored after deletion! Close and continue to delete

2.2 static background

When the background is set to static, the interactive window does not close because you click on the background. Just add data-bs-backdrop= "static" data-bs-keyboard= "false".

Put the code in the 26.2.1 example

Replace with

There is no difference in appearance, but click on the background and the pop-up box is no longer closed.

3 Scroll long content 3.1 use browser scroll bar

By default, when users' dynamic windows become too long, their scrolling is independent of the page itself, and vertical scrollbars are enabled on the browser.

Mode frame rolling pop-up window demonstrates 33 million young people who don't look at their faces and socialize.

Generation Z is becoming a new force in global consumption. This group of mobile Internet aborigines born between 1995 and 2009 have formed an inclusive and critical aesthetic tendency in a world of rapid economic growth, multicultural collision and unprecedented prosperity of information and information. they regard personal interests and likes and dislikes as the basic principles of social interaction, which leads to the trend of "tribalization" and "isolation" of the new generation of social interaction.

This new digital behavior dominated by Generation Z is transforming the shape of global mobile applications with great fanfare, bringing new possibilities to the long-silent ecology of mobile social applications.

For a long time, the core reason for Wechat's position as a "social overlord" is that it skillfully moves the social ecology of acquaintances online and promotes it. In other words, Wechat solves the problem of survival. But at present, young people have more complex needs for companionship, expression and personal identity, which need to be realized in other ways. This demand is reflected in the social market and brings the personalization of a new generation of social products.

For example, Soul, a social product launched less than five years ago, has quickly opened up the market among young people. Soul's DAU has reached the order of magnitude of 10 million, an increase of 94.4% over the same period last year, of which 73.9% of DAU is Generation Z. At the same time, it also achieved 33 million MAU with a new way of social play. What is more noteworthy is that since July 2020, the average growth rate of users has been more than 105%. According to Tencent think tank data, the penetration rate of Soul in the post-1995 generation has reached the top three in the industry. On the TGI index dimension (Target Group Index, which is used to measure user preference), Soul has reached 127in the post-1995 group, far exceeding the average of 100. it is enough to reflect the popularity of Soul among the post-1995 group.

The growth path of Soul does not depend on the transfer or mapping of existing relationship chains, nor does it absorb powder through KOL or head VJ, but completes the cold start of the platform. There is no precedent for matching this form at home and abroad. How did this young social platform grow? Without the introduction of offline relationships, how can Soul ensure retention and activity?

"anti-traditional" operation strategy

Throughout the global social industry, there are three main types of social products in terms of the closed loop of the relationship chain.

The first is to copy the existing external relationship chain into social products, mainly the mapping of offline relationships such as mobile phone address book, mailbox, etc. Facebook, Wechat and QQ all belong to this category; the second is to match based on geographical location, such as "nearby people" and "making friends in the same city", which was mainly used by the previous generation of stranger social products. The third is to aggregate by topic, content, or interest, such as Clubhouse, which became popular some time ago.

But Soul does not belong to any of the above. When users enter Soul for the first time, they need to create a new identity, conduct a "soul test", and finally put a personalized tag; based on this virtual online image, users can express themselves, know others, explore the world, exchange interests and ideas, gain emotional support and identity, get information from communication, and have quality new relationships.

Close Save changes

3.2 use the pop-up scroll bar

You can add modal-dialog-scrollable to modal-dialog to create a body scrollable pop-up window.

In the 26.3.1 example

Replace with

4 vertically centered

Add modal-dialog-centered to modal-dialog to center the interactive window vertically. This setting is relatively simple, you only need to make the following changes.

There is a scroll bar below.

Copy the code

In the above example, because only part of the window is selected in the screenshot, you may not see that the following two pictures are 26.2.1 to demonstrate the display effect of pulling the window high and adding the vertical center.

5 multiple modal box switching

Switch between multiple modes, skillfully placing the data-bs-target and data-bs-Toggle properties. For example, you can switch password reset mode in an open login mode. Note that you cannot open multiple modes at the same time. This method simply switches between two separate modes.

Open first modalddd latest news first message check the next latest message The second message, check the first message.

Thank you for reading this article carefully. I hope the article "how to use Modal Box in Bootstrap" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report