旋转木马中的自定义控制间隔按钮

时间:2018-03-23 07:25:34

标签: javascript html css

以下是我在此代码中的Carousel代码我添加了两个按钮作为" glyphicon glyphicon-fast-backward"和" glyphicon glyphicon-fast-forward"如何为这两个按钮设置不同/自定义间隔而不中断其他旋转木马控件,如播放/暂停按钮,自动滑动,上一个和下一个按钮

            <div class="container">
              <br>
            <button id="toggleCarousel" style="width: 8%; height: 19px;"><i class="fa fa-pause"></i></button>
              <div id="myCarousel" class="carousel slide" style="width: 80%; float: right;">
                <!-- Indicators -->
                <ol class="carousel-indicators">
                  <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                  <li data-target="#myCarousel" data-slide-to="1"></li>
                  <li data-target="#myCarousel" data-slide-to="2"></li>
                  <li data-target="#myCarousel" data-slide-to="3"></li>
                </ol>
                <!-- Wrapper for slides -->
                <div class="carousel-inner" role="listbox">
                  <div class="item active">
                    <div class="img-title">Ch</div>
                    <img src="codeigniter_media/images/ring1.jpg" alt="Chania" width="460" height="345">
                  </div>

                  <div class="item">
                    <div class="img-title">Some other text discription goes at the top that goes a distance across the top</div>
                    <img src="codeigniter_media/images/ring2.jpg" alt="Chania" width="460" height="345">
                  </div>

                  <div class="item">
                    <div class="img-title">an Image of Flower</div>
                    <img src="/codeigniter_media/images/ring3.jpg" alt="Flower" width="460" height="345">
                  </div>
            </div>
                <!-- Left and right controls -->
                <a class="left carousel-control" href="#myCarousel" role="button" id="pre" data-slide="prev">
                  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                  <span class="sr-only">Previous</span>
                </a>
             <a class="left carousel-control" href="#myCarousel" role="button" id="fastpre" data-slide="prev">
                  <span class="glyphicon glyphicon-fast-backward" aria-hidden="true"></span>
                  <span class="sr-only">Previous</span>
                </a>
                <a class="right carousel-control" href="#myCarousel" id="nex" role="button" data-slide="next">
                  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                  <span class="sr-only">Next</span>
                </a>
            <a class="right carousel-control" href="#myCarousel" role="button" id="fastnex" data-slide="next">
                  <span class="glyphicon glyphicon-fast-forward" aria-hidden="true"></span>
                  <span class="sr-only">Next</span>
                </a>
              </div>
            </div>
            <script>
            $(function() {
              /* Initialize Carousel */
              var paused = 0;
              $('#myCarousel').carousel({
                interval: 1000,
                pause: 0
              });

              /* Play trigger */
              $('#toggleCarousel').click(function() {
                var state = (paused) ? 'cycle' : 'pause';
                paused = (paused) ? 0 : 1;
                $('#myCarousel').carousel(state);
                $(this).find('i').toggleClass('fa-play fa-pause');
              });
            });
            </script>

0 个答案:

没有答案