![](/img/trans.png)
[英]Twitter bootstrap modal appearing in wrong location, not centered and the buttons are not clickable
[英]Twitter Bootstrap Modal - not appearing
我正在寻找使用twitter bootstrap模态功能。 因此,我从文档中粘贴了复制并包含所有文件。 但每次我点击我的按钮都没有出现,我不知道为什么:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testing</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<script src="js/jquery-1.10.2.js"></script>
<script type="js/bootstrap.js"></script>
</head>
<body style="background:#bf9d93;">
<!-- Button trigger modal -->
<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" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</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>
</body>
</html>
现在根据文档,在使用部分我可以简单地使用上面的代码并通过数据属性调用模态。 因此,这是我第一次使用该元素,所以我确定它是一个愚蠢的东西,我已经看了但我不知道它是什么...
检查代码的第8行。 你有:
<script type="js/bootstrap.js"></script>
代替:
<script src="js/bootstrap.js"></script>
如果没有正确加载bootstrap.js文件,它将无法正常工作。
点击事件调用:
$('#myModal).modal({ show: true });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.