Carousel items are not showing on mobile view

34 views Asked by At

i'm using boostrap Carousel i put few items on image in laptop view it's looking perfect but on mobile view items are not showing here is laptop view enter image description here

here is the mobile view enter image description here


        <section class="hero-wrap">
        <div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                <li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
                <li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
                <li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
            </ol>
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src="images/bg_1.jpg" class="d-block w-100" alt="">
                    <div class="carousel-caption d-none d-md-block">
                        <div class="overlay"></div>
                        <div class="container">
                            <div class="row  slider-text ">
                                <div class="col-md-10 ftco-animate text-center">
                                    <br><br>
                                    <div class="icon">
                                        <span class="flaticon-lotus"></span>
                                    </div>
                                    <h1>Spa &amp; Beauty Center</h1>
                                    <div class="row justify-content-center">
                                        <div class="col-md-7 mb-3">
                                            <p>Far far away, behind the word mountains, far from the countries Vokalia
                                                and
                                                Consonantia,
                                                there live the blind texts.</p>
                                        </div>
                                    </div>
                                    <p>
                                        <a href="pricing.php" class="btn btn-primary p-3 px-5 py-4 mr-md-2">Prices</a>
                                        <a href="booking.php"
                                            class="btn btn-outline-primary p-3 px-5 py-4 ml-md-2">Booking</a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="carousel-item">
                    <img src="images/bg_2.jpg" class="d-block w-100" alt="">
                    <div class="carousel-caption d-none d-md-block">
                        <div class="overlay"></div>
                        <div class="container">
                            <div class="row slider-text">
                                <div class="col-md-10 ftco-animate text-center">
                                    <div class="icon">
                                        <span class="flaticon-lotus"></span>
                                    </div>
                                    <h1>Spa &amp; Beauty Center</h1>
                                    <div class="row justify-content-center">
                                        <div class="col-md-7 mb-3">
                                            <p>Far far away, behind the word mountains, far from the countries Vokalia
                                                and
                                                Consonantia,
                                                there live the blind texts.</p>
                                        </div>
                                    </div>
                                    <p>
                                        <a href="pricing.php" class="btn btn-primary p-3 px-5 py-4 mr-md-2">Prices</a>
                                        <a href="booking.php"
                                            class="btn btn-outline-primary p-3 px-5 py-4 ml-md-2">Booking</a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="carousel-item">
                    <img src="images/bg_3.jpg" class="d-block w-100" alt="">
                    <div class="carousel-caption d-none d-md-block">
                        <div class="overlay"></div>
                        <div class="container">
                            <div class="row slider-text">
                                <div class="col-md-10 ftco-animate text-center">
                                    <div class="icon">
                                        <span class="flaticon-lotus"></span>
                                    </div>
                                    <h1>Spa &amp; Beauty Center</h1>
                                    <div class="row justify-content-center">
                                        <div class="col-md-7 mb-3">
                                            <p>Far far away, behind the word mountains, far from the countries Vokalia
                                                and
                                                Consonantia,
                                                there live the blind texts.</p>
                                        </div>
                                    </div>
                                    <p>
                                        <a href="pricing.php" class="btn btn-primary p-3 px-5 py-4 mr-md-2">Prices</a>
                                        <a href="booking.php"
                                            class="btn btn-outline-primary p-3 px-5 py-4 ml-md-2">Booking</a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


        </div>
    </section>

And css code is

.carousel-item {
height: 100vh;
min-height: 300px;
background: no-repeat scroll center scroll;
\--webkit-background-size: cover;
background-size: cover;
}

    .carousel-item::before {
        content: "";
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        background: #000;
        opacity: 0.1;
    }
    .carousel-caption{
        bottom:75px;
        padding-left:200px;
        padding-right:50px;
    }
    @media (max-width: 600px) {
        .carousel-item {
            height: 0;
        min-height: 270px;
        }
        
    }

i'm using boostrap Carousel i put few items on image in laptop view it's looking perfect but on mobile view items are not showing here is laptop view enter image description here

here is the mobile view enter image description here

1

There are 1 answers

4
Mehdi On

It is because Bootstrap displays .d-none class as none (with !important). If you want to overwright Bootstrap and show it in small screens use inline css (in HTML). You will also then need to add style accordingly for small screens (decrease size of buttons..)

.carousel-item {
    height: 100vh;
    min-height: 300px;
    background: no-repeat scroll center scroll;
    /* --webkit-background-size: cover; */
    background-size: cover;
    }
    
        .carousel-item::before {
            content: "";
            display: block;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            background: #000;
            opacity: 0.1;
        }
        .carousel-caption{
            bottom:75px;
            padding-left:200px;
            padding-right:50px;
        }
        @media (max-width: 600px) {
            .carousel-item {
                height: 0;
            min-height: 270px;
            }
                      .carousel-caption{
            min-width: 200px !important;
            font-size: 10px;
            left: -20% !important;
          }

          .carousel-caption .container{
            min-width: 100px !important;
            padding: 0 !important;

          }

          .carousel-caption h1{
            font-size: 15px;
          }

          .carousel-caption p a.btn{
            font-size: 2vw;
            padding: 5px !important;
          }
            
        }
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
   <section class="hero-wrap">
        <div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                <li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
                <li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
                <li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
            </ol>
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src="https://picsum.photos" class="d-block w-100" alt="">
                    <div class="carousel-caption d-none d-md-block" style="display:flex !important;">
                        <div class="overlay"></div>
                        <div class="container">
                            <div class="row  slider-text ">
                                <div class="col-md-10 ftco-animate text-center">
                                    <br><br>
                                    <div class="icon">
                                        <span class="flaticon-lotus"></span>
                                    </div>
                                    <h1>Spa &amp; Beauty Center</h1>
                                    <div class="row justify-content-center">
                                        <div class="col-md-7 mb-3">
                                            <p>Far far away, behind the word mountains, far from the countries Vokalia
                                                and
                                                Consonantia,
                                                there live the blind texts.</p>
                                        </div>
                                    </div>
                                    <p>
                                        <a href="pricing.php" class="btn btn-primary p-3 px-5 py-4 mr-md-2">Prices</a>
                                        <a href="booking.php"
                                            class="btn btn-outline-primary p-3 px-5 py-4 ml-md-2">Booking</a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="carousel-item">
                    <img src="https://picsum.photos/id/237/200/300" class="d-block w-100" alt="">
                    <div class="carousel-caption d-none d-md-block" style="display:flex !important;">
                        <div class="overlay"></div>
                        <div class="container">
                            <div class="row slider-text">
                                <div class="col-md-10 ftco-animate text-center">
                                    <div class="icon">
                                        <span class="flaticon-lotus"></span>
                                    </div>
                                    <h1>Spa &amp; Beauty Center</h1>
                                    <div class="row justify-content-center">
                                        <div class="col-md-7 mb-3">
                                            <p>Far far away, behind the word mountains, far from the countries Vokalia
                                                and
                                                Consonantia,
                                                there live the blind texts.</p>
                                        </div>
                                    </div>
                                    <p>
                                        <a href="pricing.php" class="btn btn-primary p-3 px-5 py-4 mr-md-2">Prices</a>
                                        <a href="booking.php"
                                            class="btn btn-outline-primary p-3 px-5 py-4 ml-md-2">Booking</a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="carousel-item">
                    <img src="https://picsum.photos/seed/picsum/200/300" class="d-block w-100" alt="">
                    <div class="carousel-caption d-none d-md-block" style="display:flex !important;">
                        <div class="overlay"></div>
                        <div class="container">
                            <div class="row slider-text">
                                <div class="col-md-10 ftco-animate text-center">
                                    <div class="icon">
                                        <span class="flaticon-lotus"></span>
                                    </div>
                                    <h1>Spa &amp; Beauty Center</h1>
                                    <div class="row justify-content-center">
                                        <div class="col-md-7 mb-3">
                                            <p>Far far away, behind the word mountains, far from the countries Vokalia
                                                and
                                                Consonantia,
                                                there live the blind texts.</p>
                                        </div>
                                    </div>
                                    <p>
                                        <a href="pricing.php" class="btn btn-primary p-3 px-5 py-4 mr-md-2">Prices</a>
                                        <a href="booking.php"
                                            class="btn btn-outline-primary p-3 px-5 py-4 ml-md-2">Booking</a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>


        </div>
    </section>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>