Home Web Front-end Bootstrap Tutorial bootstrap modal box usage

bootstrap modal box usage

Feb 07, 2021 am 09:33 AM
bootstrap

Usage of bootstrap modal box: 1. Through the data attribute, set the "data-target="#myModal"" selector content at the same time; 2. Through js, directly use the code "$('#myModal' ).modal(options)" etc.

bootstrap modal box usage

#The operating environment of this article: Windows7 system, bootstrap3, Dell G3 computer.

bootstrap’s modal box

If you only want to use the modal box function alone, you can introduce modal.js separately, and bootstrap’s css, in bootstrap In the package, bootstrap.js can be introduced.

Usage

  1. Through the data attribute, such as setting the data-toggle='"modal" of a button, and setting the data-target= "#myModal" selector content,

  2. directly use the code $('#myModal').modal(options)

  3. through js to model The modal box is mainly composed of three parts, model-head, modal-body, and model-footer. The main content is displayed in the body. Class="close" is a closed modal box style.

  4. Several commonly used methods$('#identifier').modal('toggle') switches the modal box state

    $('#identifier'). modal('show') Show modal box

    $('#identifier').modal('hide') Hide modal box

##show.bs.modalIn Triggered after calling the show method. $('#myModal').on('show.bs.modal',function () {alert("Show modal box");});shown.bs.modalTriggered after calling the show method. $('#myModal').on('shown.bs.modal', function () {alert("Show modal completely"); });hide.bs.modalTriggered after calling the hide method. $('#myModal').on('hide.bs.modal', function () {alert("Hide modal box");});hidden.bs.modalTriggered after calling the hide method. $('#myModal').on('hidden.bs.modal', function () {alert("Completely hide the modal box"); });
Event Function Usage

Use two steps

1.Introduce the following three files in order

<link rel="stylesheet" href="../css/bootstrap.min.css">
<script sype="text/JavaScript" src="./jquery.min.js"></script>
<script sype="text/JavaScript" src="../js/bootstrap.min.js"></script>
Copy after login

2.Copy the following in the page The code

<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">开始演示模态框</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title text-center" id="myModalLabel">标题是什么</h4>
            </div>
            <div class="modal-body">
                写你HTML文本
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary">保存添加</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
Copy after login

is simple. The modal box needs a trigger. Add the following attributes to the html element that triggers the modal box.

data-toggle="modal" data-target="#myModal"

Observe the following and you will find that myModal in this

data-target="#myModal" is the id of the div where the modal box is located

(Recommended: "

bootstrap Tutorial")

The above is the detailed content of bootstrap modal box usage. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

750,000 rounds of one-on-one battle between large models, GPT-4 won the championship, and Llama 3 ranked fifth 750,000 rounds of one-on-one battle between large models, GPT-4 won the championship, and Llama 3 ranked fifth Apr 23, 2024 pm 03:28 PM

Regarding Llama3, new test results have been released - the large model evaluation community LMSYS released a large model ranking list. Llama3 ranked fifth, and tied for first place with GPT-4 in the English category. The picture is different from other benchmarks. This list is based on one-on-one battles between models, and the evaluators from all over the network make their own propositions and scores. In the end, Llama3 ranked fifth on the list, followed by three different versions of GPT-4 and Claude3 Super Cup Opus. In the English single list, Llama3 overtook Claude and tied with GPT-4. Regarding this result, Meta’s chief scientist LeCun was very happy and forwarded the tweet and

How to use layui and bootstrap together How to use layui and bootstrap together Apr 26, 2024 am 03:51 AM

LayUI and Bootstrap can be integrated in the following ways: directly introduce styles and scripts, but you need to customize CSS override rules; use Sass to override Bootstrap variables, which requires Sass environment support; use Laystrap plug-ins to encapsulate the Bootstrap style version of LayUI components; use Layui Bootstrap plugin that automatically handles style overrides and responsive layout.

Java Kafka: FAQs and Best Practices Java Kafka: FAQs and Best Practices May 08, 2024 pm 09:36 PM

KafkaJava Best Practices and FAQ Timeout while creating producer: Check connection, network and producer properties configuration. Delay or error when consuming: optimize batch size and polling interval, check consumer processing logic efficiency. Guarantee message order: Create a single-partition topic, associate key and order, and use ordered sending method. Optimize throughput and latency: increase the number of partitions, adjust batch settings, and use high-speed storage. Manage Kafka cluster: monitor performance, clean up old messages, adjust the number of partitions, replicas and retention policies.

Which is better, layui framework or bootstrap? Which is better, layui framework or bootstrap? Apr 26, 2024 am 02:21 AM

Layui and Bootstrap are two popular front-end frameworks. Layui is lightweight and modular, suitable for mobile-first development and projects with performance requirements. Bootstrap is widely used, responsive and suitable for developing large and complex applications. When choosing, consider criteria such as project size, mobile-firstness, customizability, supporting community, and more.

What is the connection between NIO technology and Reactor pattern in Java functions? What is the connection between NIO technology and Reactor pattern in Java functions? Apr 30, 2024 pm 01:09 PM

NIO technology and Reactor mode in Java functions NIO (non-blocking I/O) and Reactor mode are important technologies in Java concurrent programming. In Java functions, they are widely used through the Netty framework. NIO technology NIO is a non-blocking I/O model. Unlike traditional blocking I/O, NIO does not block the calling thread, but notifies the application through a callback mechanism when the I/O operation is ready. This enables applications to handle multiple I/O operations simultaneously, improving concurrency. In Java functions, NIO usually uses classes in the java.nio.channels package. Show

How to change layui framework to bootstrap How to change layui framework to bootstrap Apr 26, 2024 am 01:30 AM

Converting from LayUI to Bootstrap involves the following steps: 1. Import the Bootstrap library; 2. Replace UI components; 3. Adjust styles; 4. Refactor JavaScript code; 5. Adapt the layout. When converting, consider using a JavaScript framework to simplify the process, and be careful to back up your code and make any necessary additional adjustments.

PHP front-end framework integration and practice PHP front-end framework integration and practice May 01, 2024 am 11:21 AM

By integrating Bootstrap and Vue.js, you can simplify the process of building responsive, maintainable PHP web applications. Integrate Bootstrap: Install Bootstrap, load CSS and JS files in your index.php file, and use Bootstrap components in HTML. Integrate Vue.js: Install Vue.js, load the Vue.js file in the index.php file, create a Vue instance and mount it into your HTML. Practical case: Use Bootstrap and Vue.js to create a form containing input fields, buttons and Vue binding messages.

Can layui be used with bootstrap? Can layui be used with bootstrap? Apr 26, 2024 am 02:33 AM

Can. Using Layui and Bootstrap together increases flexibility, provides a rich ecosystem, and optimizes performance. However, you need to pay attention to style conflicts, component overlap, and version compatibility. It is recommended to use Layui for core logic and Bootstrap for responsive layout.

See all articles