如何在Bootstrap轮播中设置标签

时间:2017-06-28 06:45:58

标签: javascript jquery css twitter-bootstrap tabs

我试图在Bootstrap Carousel中实现四个标签/按钮。这里每个幻灯片的幻灯片包含4个标签,所以4个旋转木马滑动和4 * 4个标签完全在这里

<!-- The main page goes here -->
<div id="container" class="chart_sectn">
    <div class="main">
        <input id="tab1" type="radio" name="tabs" checked>
        <label for="tab1">Forecast</label>
        <input id="tab2" type="radio" name="tabs">
        <label for="tab2">Last Week</label>
        <input id="tab3" type="radio" name="tabs">
        <label for="tab3">Last Year</label>
        <input id="tab4" type="radio" name="tabs">
        <label for="tab4">Trend</label>
        <section id="content1">
            <div class="container">
                <div id="myCarousel" class="carousel slide" data-ride="carousel">
                    <!-- 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">
                        <div class="item active">
                            <div id="chart_div"></div>
                        </div>
                        <div class="item">
                            <h2>car 1 disp2</h2>
                        </div>
                        <div class="item">
                            <h2>car 1 disp3</h2>
                        </div>
                        <div class="item">
                            <h2>car 1 disp4</h2>
                        </div>
                    </div>
                    <!-- Left and right controls 
                        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
                          <span class="glyphicon glyphicon-chevron-left"></span>
                          <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#myCarousel" data-slide="next">
                          <span class="glyphicon glyphicon-chevron-right"></span>
                          <span class="sr-only">Next</span>
                        </a>-->
                </div>
            </div>
            <script type="text/javascript">
                $('.carousel').carousel({
                    interval: false
                }); 
            </script>
        </section>
        <section id="content2">
            <div class="container">
                <div id="myCarousel" class="carousel slide" data-ride="carousel">
                    <!-- Indicators -->
                    <ol class="carousel-indicators">
                        <li data-target="#step11" data-toggle="tab" aria-expanded="false" class="active"></li>
                        <li data-target="#step12" data-toggle="tab" aria-expanded="false"></li>
                        <li data-target="#step13" data-toggle="tab" aria-expanded="false"></li>
                        <li data-target="#step14" data-toggle="tab" aria-expanded="false"></li>
                    </ol>
                    <!-- Wrapper for slides -->
                    <div class="carousel-inner">
                        <div class="item active" id="step11">
                            <h2>car 2 disp1 </h2>
                        </div>
                        <div class="item" id="step12">
                            <h2>car 2 disp2</h2>
                        </div>
                        <div class="item" id="step13">
                            <h2>car 2 disp3</h2>
                        </div>
                        <div class="item" id="step14">
                            <h2>car 2 disp4</h2>
                        </div>
                    </div>
                    <!-- Left and right controls 
                        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
                          <span class="glyphicon glyphicon-chevron-left"></span>
                          <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#myCarousel" data-slide="next">
                          <span class="glyphicon glyphicon-chevron-right"></span>
                          <span class="sr-only">Next</span>
                        </a>-->
                </div>
            </div>
            <script type="text/javascript">
                $('#myCarousel').carousel();
                $('#myCarousel1').carousel();
                $('.carousel').carousel({
                 interval: false
                }); 
            </script>
        </section>
        <section id="content3">
            <div class="container">
                <div id="myCarousel" class="carousel slide" data-ride="carousel">
                    <!-- Indicators -->
                    <ol class="carousel-indicators">
                        <li data-target="#step21" data-toggle="tab" aria-expanded="false" class="active"></li>
                        <li data-target="#step22" data-toggle="tab" aria-expanded="false"></li>
                        <li data-target="#step23" data-toggle="tab" aria-expanded="false"></li>
                        <li data-target="#step24" data-toggle="tab" aria-expanded="false"></li>
                    </ol>
                    <!-- Wrapper for slides -->
                    <div class="carousel-inner">
                        <div class="item active" id="step21">
                            <h2>Car3 disp1</h2>
                        </div>
                        <div class="item" id="step22">
                            <div id="chart_div"></div>
                            <h2>Car3 disp2</h2>
                        </div>
                        <div class="item" id="step23">
                            <h2>Car3 disp3</h2>
                        </div>
                        <div class="item" id="step24">
                            <h2>Car3 disp4</h2>
                        </div>
                    </div>
                    <!-- Left and right controls 
                        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
                          <span class="glyphicon glyphicon-chevron-left"></span>
                          <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#myCarousel" data-slide="next">
                          <span class="glyphicon glyphicon-chevron-right"></span>
                          <span class="sr-only">Next</span>
                        </a>-->
                </div>
            </div>
            <script type="text/javascript">
                $('#myCarousel').carousel();
                $('#myCarousel1').carousel();
                $('.carousel').carousel({
                 interval: false
                }); 
            </script>
        </section>
        <section id="content4">
            <div class="container">
                <div id="myCarousel" class="carousel slide" data-ride="carousel">
                    <!-- Indicators -->
                    <ol class="carousel-indicators">
                        <li data-target="#step31" data-toggle="tab" aria-expanded="false" class="active"></li>
                        <li data-target="#step32" data-toggle="tab" aria-expanded="false"></li>
                        <li data-target="#step33" data-toggle="tab" aria-expanded="false"></li>
                        <li data-target="#step34" data-toggle="tab" aria-expanded="false"></li>
                    </ol>
                    <!-- Wrapper for slides -->
                    <div class="carousel-inner">
                        <div class="item active" id="step31">
                            <h2>Car4 disp1</h2>
                        </div>
                        <div class="item" id="step32">
                            <h2>Car4 disp2</h2>
                        </div>
                        <div class="item" id="step33">
                            <h2>Car4 disp3</h2>
                        </div>
                        <div class="item" id="step34">
                            <h2>Car4 disp4</h2>
                        </div>
                    </div>
                    <!-- Left and right controls 
                        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
                          <span class="glyphicon glyphicon-chevron-left"></span>
                          <span class="sr-only">Previous</span>
                        </a>
                        <a class="right carousel-control" href="#myCarousel" data-slide="next">
                          <span class="glyphicon glyphicon-chevron-right"></span>
                          <span class="sr-only">Next</span>
                        </a>-->
                </div>
            </div>
            <script type="text/javascript">
                $('#myCarousel').carousel();
                $('#myCarousel1').carousel();
                $('.carousel').carousel({
                 interval: false
                }); 
            </script>
        </section>
    </div>
</div>

以上是我的代码,在此我点击每个标签后,将显示一个图表。如果我们向第二张幻灯片滑动另一个图表,其中有四个标签,如4个图表,每个图表包含4个标签,我想把它放在里面carosel。任何想法或建议以更好的方式做到这一点

enter image description here

enter image description here

0 个答案:

没有答案