gpt4 book ai didi

html - Bootstrap 灯箱未弹出

转载 作者:太空宇宙 更新时间:2023-11-04 04:12:25 27 4
gpt4 key购买 nike

我正在使用 Bootstrap Lightbox 的演示,我也是网络开发的新手。我无法让灯箱工作,本例中的第一张图片 shell_small.jpg 是可见的,它显然是一个链接,但是当我点击它时,唯一值得注意的变化是 url 来自 http://127.0 .0.1:52595/index.htmlhttp://127.0.0.1:52595/index.html#demoLightbox 但页面保持不变。谁能解释发生了什么或没有发生什么?

<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-lightbox/0.6.1/bootstrap-lightbox.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-lightbox/0.6.1/bootstrap-lightbox.js">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<a data-toggle="lightbox" href="#demoLightbox" class="thumbnail">
<img src="shell_small.jpg" alt="Click to view the lightbox">
</a>
<div id="demoLightbox" class="lightbox hide fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class='lightbox-content'>
<img src="image.png">
<div class="lightbox-caption"><p>Your caption here</p></div>
</div>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>

最佳答案

问题是您在加载 jQuery 之前加载了 Lightbox 插件。在 jQuery 代码之后将 jQuery 放在 head 或 lightbox 代码中。其次,您将灯箱代码作为样式表加载。

这样做:

  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-lightbox/0.6.1/bootstrap-lightbox.js"></script>
</body>
</html>

并删除

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-lightbox/0.6.1/bootstrap-lightbox.js">

从头部开始。

关于html - Bootstrap 灯箱未弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20476692/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com