FancyBox赢得了" pop"

时间:2014-09-22 16:01:05

标签: javascript jquery twitter-bootstrap fancybox

我一直在努力让FancyBox工作2个小时,并且不知道它是如何工作的。显然我错过了一些东西,因为它只是链接到图像。

示例:我将图像链接到我的图像文件夹(拇指和大图像),当我点击图像时,它只会将我带到一个新页面并向我显示图像而不是弹出。

这是我的代码:

<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>

2 个答案:

答案 0 :(得分:0)

我看到的第一件事是你正在加载fancybox两次。选一个。

 <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>

答案 1 :(得分:0)

在html body部分里面我添加了这段代码

<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>

似乎工作正常:)