轮播多项目:未对齐的项目

时间:2018-09-20 11:56:45

标签: javascript html css frontend

我试图获得一个多项目轮播,每次按箭头,我会显示3个项目并每次滑动一个项目。

我将3个项目垂直对齐,而我想将它们水平放置。

我正在使用具有母版页的WebForms。

有人可以帮忙这个例子吗?

$(document).ready(function () {
   

    $('.carousel.carousel-multi .item').each(function () {
        var next = $(this).next();        
        if (!next.length) {
            next = $(this).siblings(':first');

        }
        next.children(':first-child').clone().attr("aria-hidden", "true").appendTo($(this));

        if (next.next().length > 0) {
            next.next().children(':first-child').clone().attr("aria-hidden", "true").appendTo($(this));

        }
        else {
            $(this).siblings(':first').children(':first-child').clone().appendTo($(this));

        }
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div id="carousel-example-multi" class="carousel carousel-multi slide" data-interval="false">
        <!-- Indicators -->
        <ol class="carousel-indicators">
            <li data-target="#carousel-example-multi" data-slide-to="0" class="active"></li>
            <li data-target="#carousel-example-multi" data-slide-to="1"></li>
            <li data-target="#carousel-example-multi" data-slide-to="2"></li>
            <li data-target="#carousel-example-multi" data-slide-to="3"></li>
            <li data-target="#carousel-example-multi" data-slide-to="4"></li>
            <li data-target="#carousel-example-multi" data-slide-to="5"></li>
        </ol>


        <!-- Wrapper for slides -->
        <div class="column">
            <div class="carousel-inner">
                <div class="item active">
                    <div class="media media-card">
                        <time class="small">10 Aug 2016</time>
                        <div class="media-category">Commodities Quarterly</div>
                        <h4 class="media-heading">
                            <a href="#">Research article 1</a>
                        </h4>
                        <a class="aside" href="#">Read more</a>

                    </div>
                </div>

                <div class="item ">
                    <div class="media media-card">
                        <time class="small">10 Aug 2016</time>
                        <div class="media-category">Commodities Quarterly</div>
                        <h4 class="media-heading">
                            <a href="#">Research article number two</a>
                        </h4>
                        <a class="aside" href="#">Read more</a>
                    </div>
                </div>

                <div class="item ">
                    <div class="media media-card">
                        <time class="small">10 Aug 2016</time>
                        <div class="media-category">Commodities Quarterly</div>
                        <h4 class="media-heading">
                            <a href="#">Number 3</a>
                        </h4>
                        <a class="aside" href="#">Read more</a>
                    </div>
                </div>

                <div class="item ">
                    <div class="media media-card">
                        <time class="small">10 Aug 2016</time>
                        <div class="media-category">Commodities Quarterly</div>
                        <h4 class="media-heading">
                            <a href="#">This is the fourth article</a>
                        </h4>
                        <a class="aside" href="#">Read more</a>
                    </div>
                </div>

                <div class="item ">
                    <div class="media media-card">
                        <time class="small">10 Aug 2016</time>
                        <div class="media-category">Commodities Quarterly</div>
                        <h4 class="media-heading">
                            <a href="#">...and this is the fifth</a>
                        </h4>
                        <a class="aside" href="#">Read more</a>
                    </div>
                </div>

                <div class="item ">
                    <div class="media media-card">
                        <time class="small">10 Aug 2016</time>
                        <div class="media-category">Commodities Quarterly</div>
                        <h4 class="media-heading">
                            <a href="#">Sixth</a>
                        </h4>
                        <a class="aside" href="#">Read more</a>
                    </div>
                </div>

            </div>
        </div>
        <!-- Controls -->
        <a class="left carousel-control" href="#carousel-example-multi" role="button" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#carousel-example-multi" role="button" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>
    </div>

任何帮助都会被重视

0 个答案:

没有答案