代码之家  ›  专栏  ›  技术社区  ›  Malik

特定高度的截面背景图像

  •  4
  • Malik  · 技术社区  · 6 年前

    我真正想达到的是把背景图像放到一个特定的高度,就像我有一个包含两个div的部分,我给了这个部分一个背景图像 哪个是

        background-image: linear-gradient(-207deg, #0EC573, #0093FF);
    

    现在我要实现的是背景图像覆盖整个 第二div 还有一部分 第一 div

    全码

     <section class="company py-4" >
            <div class="container">
                <div class="row">
                        <div class="col-12">
              <div class="mt-5 px-3">
                    <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel" data-interval="4000">
                        <ol class="carousel-indicators">
                            <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
                            <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
                            <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
                            <li data-target="#carouselExampleIndicators" data-slide-to="3"></li>
                        </ol>
    
                        <div class="carousel-inner">
                            <div class="carousel-item active">
                                <img class="img-fluid" src="{!! asset('images/Company/02.jpg') !!}">
                                <div class="mt-5 ">
                                </div>
                            </div>
                            <div class="carousel-item ">
                                <div class="justify-content-center align-items-center">
                                    <img class="img-fluid" src="{!! asset('images/Company/01.jpg') !!}">
                                </div>
                                <div class="mt-5 ">
                                </div>
                            </div>
                            <div class="carousel-item">
                                <img class="img-fluid" src="{!! asset('images/Company/03.jpg') !!}">
                                <div class="mt-5 ">
                                </div>
                            </div>
                            <div class="carousel-item">
                                <img class="img-fluid" src="{!! asset('images/Company/04.jpg') !!}">
                                <div class="mt-5 ">
                                </div>
                            </div>
                        </div>
                      <!--   <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button"data-slide="prev">
                            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                            <span class="sr-only">Previous</span>
                        </a>
                        <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
                            <span class="carousel-control-next-icon" aria-hidden="true"></span>
                            <span class="sr-only">Next</span>
                        </a> -->
    
                    </div>
                </div>            
          </div>
                </div>
            </div>
            <div class="container">
                <div class="row justify-content-center align-items-center">
                   <div class="col-12 "> 
                    <h1 class="text-left heading">Company</h1>
                    <p class="text-left description"> ALL THE DESCRIPTION</p>
                    </div>
                </div>
            </div>
        </section>
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   לבני מלכה    6 年前

    使用它(请参见jsfiddle: https://jsfiddle.net/Lfxja1e5/7/ ):

     background-size: 100% 70%;
     background-repeat: no-repeat;
    

    **如果您想在底部使用:

    background-position: bottom;
    

     .company{
          background-image:linear-gradient(-207deg,#0EC573, #0093FF);
         background-size: 100% 70%;
         background-repeat: no-repeat;
          background-position: bottom;
        }
    <section class="company py-4" >
                <div class="container d1">
                    <div class="row">
                            <div class="col-12">
                  <div class="mt-5 px-3">
                        <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel" data-interval="4000">
                            <ol class="carousel-indicators">
                                <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
                                <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
                                <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
                                <li data-target="#carouselExampleIndicators" data-slide-to="3"></li>
                            </ol>
    
                            <div class="carousel-inner">
                                <div class="carousel-item active">
                                    <img class="img-fluid" src="{!! asset('images/Company/02.jpg') !!}">
                                    <div class="mt-5 ">
                                    </div>
                                </div>
                                <div class="carousel-item ">
                                    <div class="justify-content-center align-items-center">
                                        <img class="img-fluid" src="{!! asset('images/Company/01.jpg') !!}">
                                    </div>
                                    <div class="mt-5 ">
                                    </div>
                                </div>
                                <div class="carousel-item">
                                    <img class="img-fluid" src="{!! asset('images/Company/03.jpg') !!}">
                                    <div class="mt-5 ">
                                    </div>
                                </div>
                                <div class="carousel-item">
                                    <img class="img-fluid" src="{!! asset('images/Company/04.jpg') !!}">
                                    <div class="mt-5 ">
                                    </div>
                                </div>
                            </div>
                          <!--   <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button"data-slide="prev">
                                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                                <span class="sr-only">Previous</span>
                            </a>
                            <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
                                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                                <span class="sr-only">Next</span>
                            </a> -->
    
                        </div>
                    </div>            
              </div>
                    </div>
                </div>
                <div class="container d2">
                    <div class="row justify-content-center align-items-center">
                       <div class="col-12 "> 
                        <h1 class="text-left heading">Company</h1>
                        <p class="text-left description"> ALL THE DESCRIPTION</p>
                        </div>
                    </div>
                </div>
            </section>