如何显示内部div上方的背景图像?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (51)

我想在内部div上方显示背景图片。我怎样才能做到这一点?

.adv-signup {position: relative;  background: #ffffff url("https://s6.postimg.cc/ugw1p1pcx/sprite.png ") no-repeat left top;
  width: 1000px; height: 500px;}

	
.contents {position: absolute; background: blue; width: 800px; height: 200px;top: 20px; left: 30px; }

<div class="adv-signup">
        <div class="contents">
            <div class="text">
                <h3>Sign up for E-News</h3>
                <p>Leave your email and we’ll send you regular updates on programs, events and news.</p>
            </div>

            <div class="controls">
                <input name="adv-sign-up-email-field" id="adv-sign-up-email-field" type="text" maxlength="255" value="Enter your email" />
                <a href="#" class="btn"></a>
            </div>
        </div>
<div>
提问于
用户回答回答于

尝试这个:

.contents {
    position: absolute;
    background: blue; 
    width: 800px;
    height: 200px;
    top: 20px; 
    left: 50px; /* put the real image height here, I tried 50px and I looked fine */
}
用户回答回答于

尝试这样的事情:

<nav>
  <img src="">
<nav>
<div class="contents">
  ...
</div>

扫码关注云+社区

领取腾讯云代金券