简体   繁体   English

FancyBox不会“流行”

[英]FancyBox won't “pop”

I've been trying for 2 hours to get FancyBox to work and have no clue how it isn't working. 我已经尝试了2个小时才能使FancyBox正常工作,却不知道它是如何工作的。 Obviously I am missing something because it's just linking to the image. 显然,我丢失了一些东西,因为它只是链接到图像。

Example: I link the image to my images folder (both the thumb and the large image), and when I click the image it just takes me to a new page and shows me the image rather than popping up. 示例:我将图像链接到我的图像文件夹(拇指和大图像),当我单击图像时,它只是将我带到新页面并向我显示该图像而不是弹出。

Here is my code: 这是我的代码:

<head>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/stylish-portfolio.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">

    <!-- 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.4.2/respond.min.js"></script>
    <![endif]-->

    <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/stylish-portfolio/fancybox/source/jquery.fancybox.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="/stylish-portfolio/fancybox/source/helpers/jquery.fancybox-thumbs.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="/stylish-portfolio/fancybox/source/helpers/jquery.fancybox-buttons.css" media="screen"/>
    <script type="text/javascript" src="/stylish-portfolio/fancybox/source/jquery.fancybox.pack.js"></script>
    <script type="text/javascript" src="/stylish-portfolio/fancybox/source/jquery.fancybox.js"></script>
    <script type="text/javascript" src="/stylish-portfolio/fancybox/source/helpers/jquery.fancybox-buttons.js"></script>
    <script type="text/javascript" src="/stylish-portfolio/fancybox/source/helpers/jquery.fancybox-thumbs.js"></script>
    <script type="text/javascript" src="/stylish-portfolio/fancybox/source/helpers/jquery.fancybox-media.js"></script>



    <script type="text/javascript">
        $(document).ready(function() {
        $(".fancyImg").fancybox();
});
        </script></head>


    <div class="row">
                        <div class="col-md-6">
                            <div class="portfolio-item">
                                <a class="fancyImg" href="img/portfolio-2.jpg" title="Lorem ipsum dolor sit amet"><img src="img/portfolio-2.jpg" alt="" /></a>
                            </div>
                        </div>

First thing I see is your are loading fancybox twice. 我首先看到的是您两次加载了fancybox。 Pick one. 选一个。

 <script type="text/javascript" src="/stylish-portfolio/fancybox/source/jquery.fancybox.pack.js"></script>
 <script type="text/javascript" src="/stylish-portfolio/fancybox/source/jquery.fancybox.js"></script>

Inside the html body section I added this code 在html主体部分中,我添加了以下代码

<a class="fancyImg" href="img1.jpg" title="Lorem ipsum dolor sit amet"><img src="img1.jpg" alt="" /></a>

        <script type="text/javascript">
            $(document).ready(function() {
                $(".fancyImg").fancybox();
                    type:"iframe"
                    });
        </script>

And it seems to be working fine :) 它似乎工作正常:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM