我正在使用Fancybox在我的网站上创建一个图库 - Asp.Net MVC
我已经添加了所有库,但是,图像似乎在新标签中加载,而不是像侧面带箭头的pop一样工作。
以下是我在视图中的内容:
@{
ViewBag.Title = "Gallery";
}
<head>
<!-- Add jQuery library -->
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js">
</script>
<link href="../../Content/jquery.fancybox.css" rel="stylesheet"
type="text/css" />
<script src="../../Scripts/jquery.fancybox.pack.js" type="text/javascript">
</script>
<link href="../../Content/jquery.fancybox-buttons.css" rel="stylesheet"
type="text/css" />
<script src="../../Scripts/jquery.fancybox-buttons.js"
type="text/javascript"></script>
<script src="../../Scripts/jquery.fancybox-thumbs.js"
type="text/javascript"></script>
<link href="../../Content/jquery.fancybox-thumbs.css" rel="stylesheet"
type="text/css" />
<script src="../../Scripts/jquery.fancybox-media.js" type="text/javascript">
</script>
</head>
<script type="text/javascript">
$(document).ready(function () {
$(".fancybox").fancybox({
openEffect: 'none',
closeEffect: 'none',
});
});
</script>
以下是我想添加的一些图片:
<body>
<br />
<div class="bodyText">
<center>
<h1>Gallery</h1>
<p>Pictures taken by me in Agadir (Morocco), Dubai (UAE) and Sylhet (Bangladesh)</p>
<br /><br />
</center>
<!--inserting the images and adding descriptions-->
<center>
<a class="fancybox" rel="gallery" href="../../Content/images/agadir.jpg" title="Marina"><img src="../../Content/images/rsz_agadir.jpg" style='border:2px solid #ffffff' alt="" hspace="5" /></a>
<a class="fancybox" rel="gallery" href="../../Content/images/agadirmountain.jpg" title="Atlas Mountains trip"><img src="../../Content/images/rsz_agadirmountain.jpg" style='border:2px solid #ffffff' alt="" hspace="5" /></a>
<a class="fancybox" rel="gallery" href="../../Content/images/agadirsunset.jpg" title="Sunset in Agadir"><img src="../../Content/images/rsz_agadirsunset.jpg" style='border:2px solid #ffffff' alt="" hspace="5" /></a>
我在这里添加了一个小提琴:https://dotnetfiddle.net/MYo1WG
答案 0 :(得分:0)
尝试以下方法:
<a class="fancybox" data-fancybox-group="gallery" href="../../Content/images/agadir.jpg" title="Marina"><img src="../../Content/images/rsz_agadir.jpg" style='border:2px solid #ffffff' alt="" hspace="5" /></a>
<a class="fancybox" data-fancybox-group="gallery" href="../../Content/images/agadirmountain.jpg" title="Atlas Mountains trip"><img src="../../Content/images/rsz_agadirmountain.jpg" style='border:2px solid #ffffff' alt="" hspace="5" /></a>
<a class="fancybox" data-fancybox-group="gallery" href="../../Content/images/agadirsunset.jpg" title="Sunset in Agadir"><img src="../../Content/images/rsz_agadirsunset.jpg" style='border:2px solid #ffffff' alt="" hspace="5" /></a>
data-fancybox-group是fancybox插件允许您遍历图库的属性,如旋转木马。
编辑:
https://dotnetfiddle.net/YGj6rZ
在你的小提琴中,我没有看到任何错误,我从头部和身体标签之间移动了脚本,并将其放在头部标签中。然后我只是从花式框中加载了js和css脚本。它从打开选项卡到使用插件。
重新加载脚本和css文件的方式肯定有问题。答案 1 :(得分:0)
检查开发人员工具,您的网页上有JS错误 -
Select-Object
解决此问题,它应该可行。另一条消息应该给你一个线索:
Uncaught ReferenceError: $ is not defined