您好我有一个小问题,链接或所谓的引用文本与Bootstrap弹出窗口我不知道它是如何工作的这里是代码:
当用户点击My little Pontus 2时,它应弹出一个带有文字“...”的弹出窗口。
<a href="#" class="list-group-item">My little Pontus 2</a>
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-sm">
<div class="modal-content">
...
</div>
</div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
答案 0 :(得分:1)
首先,您需要将所有必需的库包含在项目中。这些是jquery
,bootstrap css
和bootstrap js
个文件。
然后,您需要向id
提供Modal
,并id
将link
与data-toggle="modal"
一起包括在内,modal
该链接会触发所需的<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<a href="#" class="list-group-item" data-toggle="modal" data-target="#myModal">My little Pontus 2</a>
<div id="myModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-sm">
<div class="modal-content">
...
</div>
</div>
</div>
。
这是您的更新代码:
variable && variable2 && variable3
&#13;
答案 1 :(得分:0)
看看这个:(你错过了data-toggle="modal"
)
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" 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">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>