简体   繁体   中英

background image not showing on div

My background-image is not showing on my div element. Background-color works just fine, but using an image doesn't show.

 .scifititle { width: 50%; position: absolute; top: 1080px; left: 350px; }.scifibg { background-image: url(images/stars.gif); margin-top: 1200px; width: 1280; height: 276px; }
 <div class="scifibg"> <img class="scifititle" src="images/sci-fi-title.png" alt=""> </div>

Your Background image not showing - maybe the image location is wrong. I checked your CSS code, I think you did some wrong CSS. Please try this HTML & CSS code. I hope it will help you perfactly.

<div class="scifibg">
    <img class="scifititle" src="https://lh3.googleusercontent.com/p4M1mK1Lbtc2tt54b6JUQUJ5U8RcwHnEAPH7_87X2NH9Rc8N9ek0Xm2BUq_wmLuOWXlylcDlZFOg4xF3aQtwsyF9frOHoqiQdWVpG-v4VO-Jb_4lIQ" alt="Google Map Mark Icon">
</div>

.scifibg {
  width: 100%;
  height: 100vh;
  padding: 100px 0;
  text-align: center;
  background-size: auto;
  background-repeat: no-repeat;
  background-position: center center;
  background-image: url(https://i.pinimg.com/originals/31/00/ec/3100ecd92a583cb03dec1f7be1fa0924.png);
} 
.scifititle {
  max-width: 570px;
  display: inline-block;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM