轮播项目未显示在移动视图上

问题描述 投票:0回答:1

我正在使用 boostrap Carousel,我在笔记本电脑视图中的图像上放置了一些项目,它看起来很完美,但在移动视图上项目没有显示 这是笔记本电脑视图

这是手机视图


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

我正在使用 boostrap Carousel,我在笔记本电脑视图中的图像上放置了一些项目,它看起来很完美,但在移动视图上项目没有显示 这是笔记本电脑视图

这是手机视图

html css bootstrap-4 carousel
1个回答
0
投票

这是因为 Bootstrap 将 .d-none 类显示为 none(带有 !important)。如果您想覆盖 Bootstrap 并在小屏幕中显示它,请使用内联 css(在 HTML 中)。然后,您还需要为小屏幕添加相应的样式(减小按钮的大小..)

.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;
            }
            
        }
    <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:block !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:block !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:block !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>

© www.soinside.com 2019 - 2024. All rights reserved.