Bootstrap模态对话框没有显示

时间:2014-09-26 21:21:58

标签: twitter-bootstrap modal-dialog

我正在尝试在我的页面中使用bootstrap模式:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Bootstrap Modal</title>
    <link rel="stylesheet" type="text/css" href="css/lib/bootstrap.min.css">
</head>
<body>
<div class="container">
    <div id="example" class="modal hide fade in" style="display: none; ">
        <div class="modal-header">
            <a class="close" data-dismiss="modal">×</a>
            <h3>This is a Modal Heading</h3>
        </div>
        <div class="modal-body">
            <h4>Text in a modal</h4>
            <p>You can add some text here.</p>
        </div>
        <div class="modal-footer">
            <a href="#" class="btn btn-success">Call to action</a>
            <a href="#" class="btn" data-dismiss="modal">Close</a>
        </div>
    </div>
    <p><a data-toggle="modal" href="#example" class="btn btn-primary btn-large">Display modal</a></p>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://www.w3resource.com/twitter-bootstrap/twitter-bootstrap-v2/js/bootstrap-modal.js"></script>
</body>
</html>

当我点击链接&#34;显示模态&#34;时,我能够看到叠加效果,因为我已经包含了所有必需的引导程序文件,但模态对话框没有显示出来。 请帮忙。

2 个答案:

答案 0 :(得分:2)

使用引导源中的链接:

<link href="bootstrap-3.2.0/css/bootstrap-theme.min.css" rel="stylesheet" />
    <link href="bootstrap-3.2.0/css/bootstrap.min.css" rel="stylesheet" />

 Your HTML content

   <script src="bootstrap-3.2.0/js/bootstrap.js"></script>
    <script src="bootstrap-3.2.0/js/bootstrap.min.js"></script>

并尝试此代码

 <p><a data-toggle="modal" href="#example" class="btn btn-primary btn-large">Display modal</a></p>
 <div class="modal fade" id="example" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
         <a class="close" data-dismiss="modal">×</a>
            <h3>This is a Modal Heading</h3>
      </div>
      <div class="modal-body">
       <h4>Text in a modal</h4>
            <p>You can add some text here.</p>
      </div>
      <div class="modal-footer">
      <a href="#" class="btn btn-success">Call to action</a>
            <a href="#" class="btn" data-dismiss="modal">Close</a>
      </div>
    </div>
  </div>
</div>

DEMO

答案 1 :(得分:0)

使用bootstrap minified javascript版本而不是普通版本。 使用以下。

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>