gpt4 book ai didi

html - 在一页上 Bootstrap 2 个模式?

转载 作者:行者123 更新时间:2023-11-28 00:45:56 25 4
gpt4 key购买 nike

我想在一页上制作 2 个模式,一个用于登录表单,另一个用于注册表单。以下是声明

<div class="modal fade" id="signUpModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal fade" id="signInModal" tabindex="-1" role="dialog" aria-hidden="true">

这里是显示模态的链接:

<a class="nav-link" data-toggle="modal" data-target="#signUpModal">Sign Up</a>
<a class="nav-link" data-toggle="modal" data-target="#signInModal">Sign In</a>

当我单击指向#signUpModal 的链接时,它工作正常,但是当我单击指向#signInModal 的链接时,没有任何反应,没有显示模态。如果我随后单击指向#signUpModal 的链接,#signInModal 将显示堆叠在#signUpModal 之上。

如何让第二个模态框正确显示?

最佳答案

使用代码如下:

注意!

请注意不要设置相同的 id 两次... id 是唯一的,您可以在每个页面中使用一次(例如: id="exampleModalLabel" 所以在第二个模型中设置 id="exampleModalLabel2")

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalIn">
Sing in
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModalIn" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Sing in</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalOut">
Sign out
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModalOut" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel2">Sign out</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>

关于html - 在一页上 Bootstrap 2 个模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53533990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com