【发布时间】:2020-12-24 18:14:52
【问题描述】:
我只是在遵循 YouTube 教程时从 Bootstrap 复制/粘贴了以下代码,但它不会为我弹出。我所做的只是从网站复制/粘贴(与视频中的完全一样),但我点击了按钮,没有任何反应。
我希望此代码弹出表单供用户填写。
知道什么会导致这个问题吗?
<!-- Button trigger modal Source: https://getbootstrap.com/docs/4.0/components/modal/ -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</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>
完整代码:
{% load static %}
<html>
<head>
<title>Polling</title>
<link href="//fonts.googleapis.com/css?family=Lobster&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</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>
<div class="container">
<div class="jumbotron">
<div class="card">
<div class="card-header">
Featured Item(s)
</div>
<div class="card-body">
<h1 style="font-family: Graphik Black; font-size: 20px">Apple iPhone XS (AT&T)</h1>
<p class="card-text">This is a description.</p>
<div class="row">
<div class="col-md-12">
<button type="button" class="btn btn-success badge-pill float-right" style="font-size: 12px; width:55px">+ New</button>
</div>
</div>
<br>
<table class="table table-hover">
<thead>
<tr style="font-family: Graphik Black; font-size: 14px">
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
</tr>
</thead>
<tbody>
<tr style="font-family: Graphik; font-size: 12px">
<th scope="row" class="container">1</th>
<td>Mark</td>
<td>Otto</td>
<td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px">Remove</button></td>
</tr>
<tr style="font-family: Graphik; font-size: 12px">
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px">Remove</button></td>
</tr>
<tr style="font-family: Graphik; font-size: 12px">
<th scope="row">3</th>
<td colspan="2">Larry the Bird</td>
<td><button type="button" class="btn btn-danger btn-sm badge-pill" style="font-size: 11px; width:60px">Remove</button></td>
</tr>
</tbody>
</table>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
</div>
</body>
</html>
【问题讨论】:
标签: javascript html jquery css twitter-bootstrap