Background image doesn't show when defined in stylesheet

后端 未结 2 1892
情话喂你
情话喂你 2021-02-20 10:36

I am very new to css so this maybe a simple answer. I have 2 scenarios and 1 works the other doesn\'t. I hope someone can help me out.

WORKS:



        
相关标签:
2条回答
  • 2021-02-20 11:06

    In my case:

    I had a CSS folder. So, inside my CSS folder I had my style.css so I was typing inside my style.css the following:

    background: url('img/mybgimg.jpg')

    instead of

    background: url('../img/mybgimg.jpg')

    ...I hope this can help to anyone who is having the same issue.

    0 讨论(0)
  • 2021-02-20 11:16

    It looks like your CSS file is in the views/default/ folder, while the image is in the views/default/images/ folder.

    Define image paths in your CSS relative to the CSS file, not the HTML file that displays everything:

    background-image:url('images/home.jpg');
    
    0 讨论(0)
提交回复
热议问题