特定高度的部分的背景图像

时间:2018-06-07 07:03:11

标签: html css styles sections

我真正希望实现的是将背景图像放到特定的高度,就像我有一个包含两个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 个答案:

答案 0 :(得分:2)

使用它(参见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>