1

我正在尝试制作一个类似于此 IMDB 页面底部“喜欢此内容的人也喜欢”部分中的 jquery 轮播

我想我会使用isotopercarousel,其中 isotope 会将我的所有项目以类似网格的格式对齐,我会使用 rcarousel 使用 AJAX 添加新网格并滑动它们。抱歉,我没有太多代码,而且我在开始这个项目时遇到了麻烦。请指出一个可以完成此任务的插件,或者让我知道我的方式是否可行。

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

HTML:

<div id="reco" class="span4">
    <div class="reco-group">
        <div class="movie item-parent"><a title="Sin city" class="movie-link"><img src="images/1.jpg" /></a></div>
        <div class="movie item-parent"><a title="Annie Hall" class="movie-link"><img src="images/2.jpg" /></a></div>
        <div class="movie item-parent"><a title="Madagascar 3" class="movie-link"><img src="images/3.jpg" /></a> </div>
        <div class="movie item-parent"><a title="As Good As It Gets" class="movie-link"><img src="images/4.jpg" /></a></div>
    </div>
</div>

jQuery:

$('#reco').rcarousel({
});

var $container = $('.reco-group');
$container.imagesLoaded(function() { 
    $container.isotope({
        itemSelector: '.movie',
        animationOptions: {
            duration: 750,
            easing: 'linear',
            queue: false
        },
        containerStyle:{
            position:'relative'
        }
    });
});
4

2 回答 2

0

即使我发现了这个。我使用TinyCarousel插件来做到这一点。我将所有元素分组在一个特定的矩阵中,如下所示:

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

如插件网站的源代码所述,我包括了必要的 CSS 和 JS。还有一个简单的 jquery 行:

$('#reco').tinycarousel();  

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

于 2013-01-02T14:05:13.637 回答
0

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

我使用了 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>

测试:http: //jsfiddle.net/d59phwrt/

更新:

上一个解决方案的分页存在问题。所以我使用 owl-carousel 来做同样的事情。

http://owlgraphic.com/owlcarousel/index.html#how-to

此解决方案优于上述解决方案。示例代码如下。

<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>
于 2014-09-29T09:34:54.203 回答