一个页面上有多个bxSlider实例

时间:2013-10-16 15:17:01

标签: javascript jquery slideshow bxslider

我在一个页面上有四个幻灯片,我想在循环中运行,使用bxSlider

我对标记和CSS很了不起,但还不熟悉javascript。我想我必须错过一个关键元素,因为目前没有任何幻灯片正在运行。我希望得到一些帮助让所有四个人都能上班。谢谢!

JS:

<script type="text/javascript" src="js/jquery.bxslider.min.js"></script>

  <script type="text/javascript">
  $('#slider1').bxSlider({
    auto: true,
    autoControls: true,
    pause: 3000,
    slideMargin: 20
  });

  $('#slider2').bxSlider({
    auto: true,
    autoControls: true,
    pause: 3000,
    slideMargin: 20
  });

  $('#slider3').bxSlider({
    auto: true,
    autoControls: true,
    pause: 3000,
    slideMargin: 20
  });

  $('#slider4').bxSlider({
    auto: true,
    autoControls: true,
    pause: 3000,
    slideMargin: 20
  });
  </script>

CSS:

.slider {
    position: relative;
    float: right;
    padding-right: 400px;
    margin-left: 40px;
    height: 350px;
}

.slider img {
    position: absolute;
    max-width: 350px;
    height: auto;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px;
    top: 0;
    left: 0;
    z-index: 8;
}

标记式:

<div>
    <div class="slider">
        <ul id="slider1">
            <li><img src="images/.../art-1.jpg" /></li>
            <li><img src="images/.../art-2.jpg" /></li>
            <li><img src="images/.../art-3.jpg" /></li>
            <li><img src="images/.../art-4.jpg" /></li>
            <li><img src="images/.../art-5.jpg" /></li>
        </ul>
    </div>
</div>

<div>
    <div class="slider">
        <ul id="slider2">
            <li><img src="images/.../bnl-1.jpg" /></li>
            <li><img src="images/.../bnl-2.jpg" /></li>
            <li><img src="images/.../bnl-3.jpg" /></li>
            <li><img src="images/.../bnl-4.jpg" /></li>
            <li><img src="images/.../bnl-5.jpg" /></li>
        </ul>
    </div>
</div>

<div>
     <div class="slider">
        <ul id="slider3">
            <li><img src="images/.../bge-1.jpg" /></li>
            <li><img src="images/.../bge-2.jpg" /></li>
            <li><img src="images/.../bge-3.jpg" /></li>
            <li><img src="images/.../bge-4.jpg" /></li>
            <li><img src="images/.../bge-5.jpg" /></li>
        </ul>
    </div>
</div>

<div>
     <div class="slider">
        <ul id="slider4">
            <li><img src="images/.../rtb-1.jpg" /></li>
            <li><img src="images/.../rtb-2.jpg" /></li>
            <li><img src="images/.../rtb-3.jpg" /></li>
            <li><img src="images/.../rtb-4.jpg" /></li>
            <li><img src="images/.../rtb-5.jpg" /></li>
        </ul>
    </div>
</div>

0 个答案:

没有答案