nnmmss
nnmmss

Reputation: 2974

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:

enter image description here

but I want the next and previous button outside of pictures like this: enter image description here

how can I do that?

Upvotes: 0

Views: 2521

Answers (1)

Paul
Paul

Reputation: 1422

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;
}

Upvotes: 1

Related Questions