Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 多元素网格的旋转/滑块_Jquery - Fatal编程技术网

Jquery 多元素网格的旋转/滑块

Jquery 多元素网格的旋转/滑块,jquery,Jquery,我正在尝试制作一个jquery旋转木马,类似于本文底部“喜欢这个的人也喜欢”一节中的内容 我想我会使用和同位素将我的所有项目以类似网格的格式对齐,我会使用rcarousel使用AJAX添加新的网格并滑动它们。 对不起,我没有太多的代码,我在开始这个项目时遇到了困难。请告诉我一个插件,可以做到这一点,或者让我知道,如果我的方式是可行的 我现在得到的是这个,显然根本不起作用: HTML: 即使我找到了。我用插件做的。我将所有元素分组到一个特定矩阵中,如下所示: <div id="reco" c

我正在尝试制作一个jquery旋转木马,类似于本文底部“喜欢这个的人也喜欢”一节中的内容

我想我会使用和同位素将我的所有项目以类似网格的格式对齐,我会使用rcarousel使用AJAX添加新的网格并滑动它们。 对不起,我没有太多的代码,我在开始这个项目时遇到了困难。请告诉我一个插件,可以做到这一点,或者让我知道,如果我的方式是可行的

我现在得到的是这个,显然根本不起作用:

HTML:

即使我找到了。我用插件做的。我将所有元素分组到一个特定矩阵中,如下所示:

<div id="reco" class="span4">
    <a class="buttons prev" href="#">left</a>
        <div class="viewport">
            <ul class="overview">
                <li class="movie-group">
                    <span class="movie"><a title="Sin city" class="movie-link"><img src="images/1.jpg" /></a></span>
                    <span class="movie"><a title="Annie Hall" class="movie-link"><img src="images/2.jpg" /></a></span>
                    <span class="movie"><a title="Madagascar 3" class="movie-link"><img src="images/3.jpg" /></a></span>
                    <span class="movie"><a title="As Good As It Gets" class="movie-link"><img src="images/4.jpg" /></a></span>
                </li>
                <li class="movie-group">
                    <span class="movie"><a title="Sin city" class="movie-link"><img src="images/1.jpg" /></a></span>
                    <span class="movie"><a title="Annie Hall" class="movie-link"><img src="images/2.jpg" /></a></span>
                    <span class="movie"><a title="Madagascar 3" class="movie-link"><img src="images/3.jpg" /></a></span>
                    <span class="movie"><a title="As Good As It Gets" class="movie-link"><img src="images/4.jpg" /></a></span>
                </li>
            </ul>
        </div>
    <a class="buttons next" href="#">right</a>
</div>

就这样。希望它对其他人也有帮助。

我今天也在尝试做同样的事情,当我搜索时,我来到了这个页面,但这个答案对我不起作用。下面是我是如何做到这一点的

我使用了responsivecarousel:basilio.github.io/responsivecarousel/how-to-use

检查下面给出的示例

<!DOCTYPE html>
<html>
    <head>
        <title>jquery grid carousel</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script type="text/javascript" src="http://basilio.github.io/responsiveCarousel/js/responsiveCarousel.js"></script>
        <script>
            jQuery(document).ready(function($){
                $('.crsl-items').carousel();
            });
        </script>
        <style>
            img {
                width: 80px;
            }
        </style>
    </head>
    <body>
        <div id="NAV-ID" class="crsl-nav">
            <a href="#" class="previous">Previous</a>
            <a href="#" class="next">Next</a>
        </div>

        <div class="crsl-items" data-navigation="NAV-ID">
            <div class="crsl-wrap">
                <figure class="crsl-item">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/sports.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/sports.jpg"><br>
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/sports.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/sports.jpg">
                </figure>
                <figure class="crsl-item">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/nature.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/nature.jpg"><br>
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/nature.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/nature.jpg">
                </figure>
                <figure class="crsl-item">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/food.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/food.jpg"><br>
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/food.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/food.jpg">
                </figure>
            </div>
        </div>
    </body>
</html>
<div id="owl-demo" class="owl-carousel">

      <div class="item">
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" />
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" /><br>
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" />
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" />
      </div>
      <div class="item"><h1>2</h1></div>
      <div class="item"><h1>3</h1></div>
      <div class="item"><h1>4</h1></div>

    </div>
    <div class="customNavigation">
      <a class="btn prev">Previous</a>
      <a class="btn next">Next</a>
      <a class="btn play">Autoplay</a>
      <a class="btn stop">Stop</a>
    </div>


    <script src="../assets/js/jquery-1.9.1.min.js"></script> 
    <script src="../owl-carousel/owl.carousel.js"></script>


    <!-- Demo -->

    <style>
    #owl-demo .item{
        background: #3fbf79;
        padding: 30px 0px;
        margin: 10px;
        color: #FFF;
        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;
        text-align: center;
    }
    .customNavigation{
      text-align: center;
    }
    .customNavigation a{
      -webkit-user-select: none;
      -khtml-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    </style>


    <script>
    $(document).ready(function() {

      var owl = $("#owl-demo");

      owl.owlCarousel({

      items : 1, //10 items above 1000px browser width
      itemsDesktop : [1000,5], //5 items between 1000px and 901px
      itemsDesktopSmall : [900,3], // 3 items betweem 900px and 601px
      itemsTablet: [600,2], //2 items between 600 and 0;
      itemsMobile : false, // itemsMobile disabled - inherit from itemsTablet option
      pagination : false

      });

      // Custom Navigation Events
      $(".next").click(function(){
        owl.trigger('owl.next');
      })
      $(".prev").click(function(){
        owl.trigger('owl.prev');
      })
      $(".play").click(function(){
        owl.trigger('owl.play',1000);
      })
      $(".stop").click(function(){
        owl.trigger('owl.stop');
      })


    });
    </script>
测试:

更新:

上一个解决方案的分页存在问题。所以我用猫头鹰旋转木马来做同样的事情

这个解决方案比上面的好。下面给出了示例代码

<!DOCTYPE html>
<html>
    <head>
        <title>jquery grid carousel</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script type="text/javascript" src="http://basilio.github.io/responsiveCarousel/js/responsiveCarousel.js"></script>
        <script>
            jQuery(document).ready(function($){
                $('.crsl-items').carousel();
            });
        </script>
        <style>
            img {
                width: 80px;
            }
        </style>
    </head>
    <body>
        <div id="NAV-ID" class="crsl-nav">
            <a href="#" class="previous">Previous</a>
            <a href="#" class="next">Next</a>
        </div>

        <div class="crsl-items" data-navigation="NAV-ID">
            <div class="crsl-wrap">
                <figure class="crsl-item">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/sports.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/sports.jpg"><br>
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/sports.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/sports.jpg">
                </figure>
                <figure class="crsl-item">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/nature.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/nature.jpg"><br>
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/nature.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/nature.jpg">
                </figure>
                <figure class="crsl-item">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/food.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/food.jpg"><br>
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/food.jpg">
                    <img src="http://basilio.github.io/responsiveCarousel/img/temp/food.jpg">
                </figure>
            </div>
        </div>
    </body>
</html>
<div id="owl-demo" class="owl-carousel">

      <div class="item">
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" />
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" /><br>
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" />
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" />
      </div>
      <div class="item"><h1>2</h1></div>
      <div class="item"><h1>3</h1></div>
      <div class="item"><h1>4</h1></div>

    </div>
    <div class="customNavigation">
      <a class="btn prev">Previous</a>
      <a class="btn next">Next</a>
      <a class="btn play">Autoplay</a>
      <a class="btn stop">Stop</a>
    </div>


    <script src="../assets/js/jquery-1.9.1.min.js"></script> 
    <script src="../owl-carousel/owl.carousel.js"></script>


    <!-- Demo -->

    <style>
    #owl-demo .item{
        background: #3fbf79;
        padding: 30px 0px;
        margin: 10px;
        color: #FFF;
        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;
        text-align: center;
    }
    .customNavigation{
      text-align: center;
    }
    .customNavigation a{
      -webkit-user-select: none;
      -khtml-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    </style>


    <script>
    $(document).ready(function() {

      var owl = $("#owl-demo");

      owl.owlCarousel({

      items : 1, //10 items above 1000px browser width
      itemsDesktop : [1000,5], //5 items between 1000px and 901px
      itemsDesktopSmall : [900,3], // 3 items betweem 900px and 601px
      itemsTablet: [600,2], //2 items between 600 and 0;
      itemsMobile : false, // itemsMobile disabled - inherit from itemsTablet option
      pagination : false

      });

      // Custom Navigation Events
      $(".next").click(function(){
        owl.trigger('owl.next');
      })
      $(".prev").click(function(){
        owl.trigger('owl.prev');
      })
      $(".play").click(function(){
        owl.trigger('owl.play',1000);
      })
      $(".stop").click(function(){
        owl.trigger('owl.stop');
      })


    });
    </script>
<div id="owl-demo" class="owl-carousel">

      <div class="item">
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" />
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" /><br>
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" />
          <img src="http://isc.stuorg.iastate.edu/wp-content/uploads/sample.jpg" />
      </div>
      <div class="item"><h1>2</h1></div>
      <div class="item"><h1>3</h1></div>
      <div class="item"><h1>4</h1></div>

    </div>
    <div class="customNavigation">
      <a class="btn prev">Previous</a>
      <a class="btn next">Next</a>
      <a class="btn play">Autoplay</a>
      <a class="btn stop">Stop</a>
    </div>


    <script src="../assets/js/jquery-1.9.1.min.js"></script> 
    <script src="../owl-carousel/owl.carousel.js"></script>


    <!-- Demo -->

    <style>
    #owl-demo .item{
        background: #3fbf79;
        padding: 30px 0px;
        margin: 10px;
        color: #FFF;
        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;
        text-align: center;
    }
    .customNavigation{
      text-align: center;
    }
    .customNavigation a{
      -webkit-user-select: none;
      -khtml-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    </style>


    <script>
    $(document).ready(function() {

      var owl = $("#owl-demo");

      owl.owlCarousel({

      items : 1, //10 items above 1000px browser width
      itemsDesktop : [1000,5], //5 items between 1000px and 901px
      itemsDesktopSmall : [900,3], // 3 items betweem 900px and 601px
      itemsTablet: [600,2], //2 items between 600 and 0;
      itemsMobile : false, // itemsMobile disabled - inherit from itemsTablet option
      pagination : false

      });

      // Custom Navigation Events
      $(".next").click(function(){
        owl.trigger('owl.next');
      })
      $(".prev").click(function(){
        owl.trigger('owl.prev');
      })
      $(".play").click(function(){
        owl.trigger('owl.play',1000);
      })
      $(".stop").click(function(){
        owl.trigger('owl.stop');
      })


    });
    </script>