安装

Easy简单的方法

单击数字以了解每个部分。

<html>
<head>

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.min.js"></script>

  <script>
    $(document).ready(function(){
      $('.slider').bxSlider();
    });
  </script>

</head>
<body>

  <div class="slider">
    <div>I am a slide.</div>
    <div>I am another slide.</div>
  </div>

</body>
</html>
1

包括bxSlider文件

此代码将所需的文件添加到网页。在初始化滑块之前,需要包含这些文件。

2

初始化bxSlider插件

此代码告诉网页开始设置滑块。没有此代码,滑块插件将在页面上不可见。

3

为滑块创建HTML

这是滑块插件将用来生成幻灯片的代码。

�其他方式

手册

2. 包含在您的网页中

// Links to the libraries needed
<link rel="stylesheet" href="/path/to/jquery.bxslider.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="/path/to/jquery.bxslider.min.js"></script>

// Initialize the slider
<script>
  $(document).ready(function(){
    $('.slider').bxSlider();
  });
</script>

// Slider HTML (change this to your own!)
<div class="slider">
  <div>I am a slide.</div>
  <div>I am another slide.</div>
</div>

Bower

1.从命令行运行

bower install bxslider --save

2.包含在您的网页中

// Links to the libraries needed
<link rel="stylesheet" href="/bower_components/bxslider/dist/jquery.bxslider.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="/bower_components/bxslider/dist/jquery.bxslider.min.js"></script>

// Initialize the slider
<script>
  $(document).ready(function(){
    $('.slider').bxSlider();
  });
</script>

// Slider HTML (change this to your own!)
<div class="slider">
  <div>I am a slide.</div>
  <div>I am another slide.</div>
</div>

NPM

1.从命令行运行

npm install bxslider --save

2.包含在您的网页中

// Links to the libraries needed
<link rel="stylesheet" href="/node_modules/bxslider/dist/jquery.bxslider.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="/node_modules/bxslider/dist/jquery.bxslider.min.js"></script>

// Initialize the slider
<script>
  $(document).ready(function(){
    $('.slider').bxSlider();
  });
</script>

// Slider HTML (change this to your own!)
<div class="slider">
  <div>I am a slide.</div>
  <div>I am another slide.</div>
</div>