Bootstrap 3弹出链接?

时间:2015-09-17 08:04:35

标签: html twitter-bootstrap

您好我有一个小问题,链接或所谓的引用文本与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>

2 个答案:

答案 0 :(得分:1)

首先,您需要将所有必需的库包含在项目中。这些是jquerybootstrap cssbootstrap js个文件。

然后,您需要向id提供Modal,并idlinkdata-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>

这是您的更新代码:

&#13;
&#13;
variable && variable2 && variable3
&#13;
&#13;
&#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">&times;</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>

更多信息:http://getbootstrap.com/javascript/#modals