Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi I want Create Slideshow with bootstrap 5. Also I want the indictors, next and previous button show center and under the slideshow. just like the "microsoft.com" slideshow.
how to do this? please help.

What I have tried:

my slide show code is:
<div class="w-100  justify-content-center " style=" height:500px">

    <div class="col-12" dir="ltr" >

        <div id="HomeSlideShow" class="carousel slide" data-bs-ride="carousel" data-bs-interval="2000">
            <div class="carousel-indicators">
                <button type="button" data-bs-target="#HomeSlideShow" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
                <button type="button" data-bs-target="#HomeSlideShow" data-bs-slide-to="1" aria-label="Slide 2"></button>
                <button type="button" data-bs-target="#HomeSlideShow" data-bs-slide-to="2" aria-label="Slide 3"></button>
            </div>
            <div class="carousel-inner">
                
                <div class="carousel-item active ">
                    <img src="~/Image/Theme/SlideShow/Home Slide Show 1.jpg" class="align-content-stretch" style="width:inherit; height:500px">
                    <div class="carousel-caption d-none d-md-block">
                        <h5>First slide label</h5>
                        <p>Some representative placeholder content for the first slide.</p>
                    </div>
                </div>

                <div class="carousel-item" >
                    <img src="~/Image/Theme/SlideShow/Home Slide Show 2.jpg" class="align-content-stretch" style="width:inherit; height:500px">
                    <div class="carousel-caption d-none d-md-block">
                        <h5>Second slide label</h5>
                        <p>Some representative placeholder content for the second slide.</p>
                    </div>
                </div>


                <div class="carousel-item">
                    <img src="~/Image/Theme/SlideShow/Home Slide Show 3.jpg" class="align-content-stretch" style="width:inherit; height:500px">
                    <div class="carousel-caption d-none d-md-block">
                        <h5>Third slide label</h5>
                        <p>Some representative placeholder content for the third slide.</p>
                    </div>
                </div>

               

            </div>
            <button class="carousel-control-prev" type="button" data-bs-target="#HomeSlideShow" data-bs-slide="prev">
                
                Previous
            </button>
            <button class="carousel-control-next" type="button" data-bs-target="#HomeSlideShow" data-bs-slide="next">
                
                Next
            </button>
        </div>
    </div>


</div>
Posted
Updated 10-Jul-23 22:51pm

1 solution

The 'slideshow' is called a carousel. There are tons of examples if you search for Bootstrap 5 Carousel - Google bootstrap 5 carousel[^]

The first one that popped up gives you multiple uses and sample code - Carousel - With controls[^] is the sample you can take a look at -
Quote:
Adding in the 'previous' and 'next' controls. We recommend using 'button' elements, but you can also use 'a' elements with 'role="button'".


<div id="carouselExampleControls" class="carousel slide" data-bs-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="..." class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="..." class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="..." class="d-block w-100" alt="...">
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev">
    
    Previous
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="next">
    
    Next
  </button>
</div>


Make sure that you referenced the bootstrap 5 file in your Head part.
 
Share this answer
 
Comments
Member 11400059 12-Jul-23 15:15pm    
thank you. but I know this and read it before. as I want Show the indicators and buttons under the slideshow. and the link you share not said how to do this.
Andre Oosthuizen 13-Jul-23 4:58am    
If you want to show it under the carousel you need to change the css properties to move it, a bit of Google would have given you some examples - Place buttons outside of carousel[^].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900