gpt4 book ai didi

css - Bootstrap 模态淡入淡出,但不弹出

转载 作者:行者123 更新时间:2023-11-28 06:35:21 24 4
gpt4 key购买 nike

我正在尝试编写一个在提交登录凭据时弹出的模式(最终我想使用 ajax 来验证 ldap 服务器并根据组成员资格弹出一个模式,但还没有)。

当我在浏览器中打开它并单击按钮时,容器会像它应该的那样逐渐变暗,但没有出现实际的模态 div。

<!doctype html>
<html lang="en">
<head>
<title>PSSST</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel=stylesheet type=text/css href="./static/style.css">
<script type=text/javascript src="./static/jquery.min.js"></script>
<link rel="stylesheet" type=text/css href="./static/bootstrap.min.css">
<script type=text/javascript src="./static/bootstrap.min.js"></script>
</head>


<body class=body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div>
<ul class="nav navbar-nav">
<li class="active"><a href="/landing">Home</a></li>

<li><a href="/">Login</a></li>

</ul>
</div>
</div>
</nav>

<div class=page>
<div class="container">
<div class="row top-buffer">
<div class="form_bg">
<form id="loginForm">
<h2 class="text-center">Login Page</h2>
<br/>
<div class="form-group">
<input type="text" class="form-control" id="username"
name="username" placeholder="Username">
</div>
<div class="form-group">
<input type="password" class="form-control"
id="password"
name="password" placeholder="Password">
</div>
<br/>
<div class="align-center">

</div>
<div class="align-center">
<button class="btn btn-default"
id="login" data-toggle="modal"
data-target="#myModal">Login</button>
</div>
</form>
</div>
</div>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal dialog">
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<p>MODAL</p>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</div>
</div>
</body>

最佳答案

您必须添加 role="document "到 <div class="modal-dialog" >

应该是这样的

<div class="modal-dialog modal-lg" role="document">

<!doctype html>
<html lang="en">
<head>
<title>PSSST</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="http://code.jquery.com/jquery-2.2.0.min.js" ></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>

</head>


<body class=body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div>
<ul class="nav navbar-nav">
<li class="active"><a href="/landing">Home</a></li>

<li><a href="/">Login</a></li>

</ul>
</div>
</div>
</nav>

<div class=page>
<div class="container">
<div class="row top-buffer">
<div class="form_bg">
<form id="loginForm">
<h2 class="text-center">Login Page</h2>
<br/>
<div class="form-group">
<input type="text" class="form-control" id="username"
name="username" placeholder="Username">
</div>
<div class="form-group">
<input type="password" class="form-control"
id="password"
name="password" placeholder="Password">
</div>
<br/>
<div class="align-center">

</div>
<div class="align-center">
<button
id="login"
data-toggle="modal" data-target="#myModal">Login</button>


</div>
</form>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" >
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Product Setting</h4>
</div>
<div class="modal-body">

</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</div>
</div>


</div>
</div>
</body>
</html>
<script>
$('#login').click(function(event) {
event.preventDefault(); });
</script>

关于css - Bootstrap 模态淡入淡出,但不弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34729418/

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