简体   繁体   中英

next and previous buttons of bootstrap carousel outside of the images

I have a botostrap carousel like this

   <div class="slider-main-container d-block  ">

            <div id="carouselExampleIndicators" class="carousel slide " data-ride="carousel">
                <ol class="carousel-indicators">

                    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>

                    @for (int i = 1; i <= Model.Sliders.Count - 1; i++)
                    {
                        <li data-target="#carouselExampleIndicators" data-slide-to="@i"></li>
                    }
                </ol>
                <div class="carousel-inner ">
                    @foreach (var item in Model.Sliders)
                    {

                        if (_sliderCount == 1)
                        {
                            <div class="carousel-item active">
                                <a href="@item.Link">
                                    <img src="~/@item.Src" class="d-block w-100">
                                </a>
                            </div>
                        }
                        else
                        {
                            <div class="carousel-item">
                                <a href="@item.Link">
                                    <img src="~/@item.Src" class="d-block w-100" alt="...">
                                </a>
                            </div>
                        }
                        _sliderCount++;
                    }

                </div>
                <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">                        
                    <span class="sr-only">Previous</span>
                </a>
                <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">                        
                    <span class="sr-only">Next</span>
                </a>
            </div>
        </div>

it makes a carousel with next and previous button inside of the images like this:

在此处输入图像描述

but I want the next and previous button outside of pictures like this: 在此处输入图像描述

how can I do that?

You can adjust the left & right in css for each. The default value is 0. Try something like 30px see below and adjust to suit your needs:

.carousel-control-next {
    right: -30px;
}

.carousel-control-previous {
    right: -30px;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM