我需要在我的网站中使用 Slick Carousel 作为 Hero Slider - JS

我仍在学习 javascript,现在我正在尝试让 Slick Carousel 工作。我需要它作为我网页中的英雄滑块

github 上的 Slick 轮播: https ://github.com/kenwheeler/slick/

这是我到目前为止所拥有的:

<html>

  <head>

  <title>Hero Slider</title>

  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.css"/>

  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.css"/>

  </head>

  <body>


  <div class="single-item">

    <div><img src="https://images.unsplash.com/photo-1604467758117-72d987cb513b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80" alt="test"></div>

    <div><img src="https://images.unsplash.com/photo-1604475935971-c390654d2332?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=321&q=80" alt="test"></div>

    <div><img src="https://images.unsplash.com/photo-1604470690311-c4136298584d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=714&q=80" alt="test"></div>

  </div>


  <script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>

  <script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>


  <script type="text/javascript">

    $('.single-item').slick();

    });

  </script>

  </body>

  </html>

你能指导我缺少什么来让这个运行吗?正如我所说,我需要它成为一个英雄滑块,之后我还将向该网页添加一个标题。所以这也应该适用。



猛跑小猪
浏览 147回答 1
1回答

函数式编程

只是有一个小错字。<html>&nbsp; <head>&nbsp; <title>Hero Slider</title>&nbsp; <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.css"/>&nbsp; <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.css"/>&nbsp; </head>&nbsp; <body>&nbsp; <div class="single-item">&nbsp; &nbsp; <div><img src="https://images.unsplash.com/photo-1604467758117-72d987cb513b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80" alt="test"></div>&nbsp; &nbsp; <div><img src="https://images.unsplash.com/photo-1604475935971-c390654d2332?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=321&q=80" alt="test"></div>&nbsp; &nbsp; <div><img src="https://images.unsplash.com/photo-1604470690311-c4136298584d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=714&q=80" alt="test"></div>&nbsp; </div>&nbsp; <script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>&nbsp; <script type="text/javascript" src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>&nbsp; <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>&nbsp; <script type="text/javascript">&nbsp; &nbsp; $('.single-item').slick();&nbsp; &nbsp; //Removed a }); here&nbsp; </script>&nbsp; </body>&nbsp; </html>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript