简体   繁体   中英

Background image not loading

I am new to html/css and I do not understand why my background image is not showing up. This is part of a simple test CSS sheet and HTML code for a simple site. I am trying to add a background-image and I have done this once and it worked and I do not know why it does not work now.

.timeline{
    width: 100%;
    height: 400px;
    display: inline-flex;
    background-image:url("img/back.jpg");
}

Your rule is wrong. You are trying to set background-image , background-position and other rules, but rule name is only background-image .

Use background instead of background-image

Your syntax for background-image is incorrect

You need to use background-repeat: repeat; for repeat. Here is doc background-image

.timeline{
  width: 100%;
  height: 400px;
  display: inline-flex;
  background-image:url("img/back.jpg");
  background-repeat: repeat;
}

Try replace this code

display:inline-flex;

to this code

display:flex;

This works. Asuming your file path is correct.

.timeline{
width: 100%;
height: 400px;
display: inline-flex;

background-image: url(img/back.jpg); }

.timeline{
  width: 100%;
  height: 400px;
  display: inline-flex;
  background-image:url("./img/back.jpg");

}

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