我目前正在尝试重新创建this页面,现在看起来不错,但是当我尝试添加iphone图片时,页面变得像this线性渐变一样,我放在背景图片的底部并按下了按钮离开。有什么办法可以解决这个问题,以便线性渐变仅覆盖背景图像?谢谢

#body {
    background: url(assets/bg_home.jpg) no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: 100% 70%;
    background-position: top center;
    display: block;
    position: relative;
}

#body::before {
    content: "";
    background-image: linear-gradient(#1659e0, #489AEA);
    opacity: 0.5;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    position: absolute;
}




<div id="body">
    <nav>
        <!--navbar here-->
    </nav>

    <div class="container">
        <div class="row">
            <div class="col-md-8 content">
                <h1>Meet BestApp</h1>
                <h1>The new world for chat</h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis deleniti cumque, odit atque molestiae totam facere aliquam sed cum perspiciatis quam, at sequi, corporis distinctio. Fugit nam, nesciunt quaerat pariatur.</p>
            </div>
            <div class="col-md-4 image">
                <img src="assets/phone.jpg" alt="phone ">
            </div>
        </div>
    </div>
</div>

<div class="container">
    <div class="row">
        <div class="col-md-8">
            <button class="button"> LEARN MORE</button>
            <button class="button"><i class="fa fa-cloud-download" aria-hidden="true"></i> DOWNLOAD APP</button>
        </div>
    </div>
</div>

最佳答案

最简单的方法可能是使电话在其所在容器的外部流血。您可以通过将其设置为position: absolute;来实现。



#body {
    background: url(assets/bg_home.jpg) no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: 100% 70%;
    background-position: top center;
    display: block;
    position: relative;
}

#body::before {
    content: "";
    background-image: linear-gradient(#1659e0, #489AEA);
    opacity: 0.5;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    position: absolute;
}

.image img {
  position:absolute;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div id="body">
    <nav>
      navigation
    </nav>

    <div class="container">
        <div class="row">
            <div class="col-md-8 content">
                <h1>Meet BestApp</h1>
                <h1>The new world for chat</h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis deleniti cumque, odit atque molestiae totam facere aliquam sed cum perspiciatis quam, at sequi, corporis distinctio. Fugit nam, nesciunt quaerat pariatur.</p>
            </div>
            <div class="col-md-4 image">
                <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/IPhone_7_Jet_Black.svg/150px-IPhone_7_Jet_Black.svg.png" alt="phone ">
            </div>
        </div>
    </div>
</div>

<div class="container">
    <div class="row">
        <div class="col-md-8">
            <button class="button"> LEARN MORE</button>
            <button class="button"><i class="fa fa-cloud-download" aria-hidden="true"></i> DOWNLOAD APP</button>
        </div>
    </div>
</div>

07-26 00:20