在bootstrap carousel /asp.net mvc5中添加动态项

时间:2017-09-29 09:06:29

标签: carousel bootstrap-4 asp.net-mvc-5

所以这就是观点:

e@model IEnumerable<CMSFC.Models.ContentHtml>



<div id="my-carousel" 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>

    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
        @{int i = 0;}
        @foreach (var item in Model)
        {
            i++;
            var active = i == 1 ? "active" : "";
            <div class="item @active">
                <a href="@Url.Action("Details", "ContentHtml", new { Id = item.Id })">
                    <img src="@Url.Content(item.Ctl)" alt="" height="500" width="500">
                </a>
            </div>
        }
    </div>

    <!-- Left and right controls -->
    <a class="left carousel-control" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>

我有左右控件的问题,当我触摸它们时,它们不受影响,幻灯片只是自动移动,但左右控制不起作用。

0 个答案:

没有答案