我的Carousel Materialise不起作用。我使用的是最新版本1.0.0

时间:2018-05-02 18:43:57

标签: javascript css carousel materialize css-frameworks

我的问题是我的旋转木马没有显示出来。它似乎只是白色,没有什么。 这是我的旋转木马实现的html代码..它来自他们的网站http://materializecss.com/carousel.html

   <div class="carousel carousel-slider center">
            <div class="carousel-fixed-item center">
              <a class="btn waves-effect white grey-text darken-text-2">button</a>
            </div>
            <div class="carousel-item red white-text" href="#one!">
              <h2>First Panel</h2>
              <p class="white-text">This is your first panel</p>
            </div>
            <div class="carousel-item amber white-text" href="#two!">
              <h2>Second Panel</h2>
              <p class="white-text">This is your second panel</p>
            </div>
            <div class="carousel-item green white-text" href="#three!">
              <h2>Third Panel</h2>
              <p class="white-text">This is your third panel</p>
            </div>
            <div class="carousel-item blue white-text" href="#four!">
              <h2>Fourth Panel</h2>
              <p class="white-text">This is your fourth panel</p>
            </div>
          </div>

这里是我的旋转木马的javascript,也是他们网站上的代码,它位于我身体标签的底部。

var instance = M.Carousel.init({
fullWidth: true});

// Or with jQuery

$('.carousel.carousel-slider').carousel({
fullWidth: true
});

具体来说,这是我的物化和js的链接。

<link rel = "stylesheet" type = "text/css" href = "materialize/css/materialize.css">
<link rel = "stylesheet" type = "text/css" href = "materialize/css/materialize.min.css">
<link rel = "stylesheet" type = "text/css" href = "css/style.css">

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>     
<script src = "https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js"></script>       



<script type = "text/javascript" src = "https://code.jquery.com/jquery-2.1.1.min.js"></script>    
<script type = "text/javascript" src = "js/news.js"></script>         
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

1 个答案:

答案 0 :(得分:0)

您需要选择轮播元素

var elems = document.querySelectorAll('.carousel');

然后在初始化时将其作为参数传递。

var instances = M.Carousel.init(elems, options);