Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Background Image not working Css

    Hi, This is my first post here! I am stuck with some CSS, I am trying to link an image to my stylesheet but it does not work unless it is in the style sheet folder bearing in mind that the image is in a diffrent folder. My folder structure is:
    - As > Css > style.css
    - As > images > banner.jpg

    when I do <img src="..\images\banner.jpg"> the image works perfectly fine, when I put that into my css nothing comes up:
    background-image:url('..\images\banner.jpg');

    tried a lot of diffrent things such as:
    background-image:url('\images\banner.jpg');
    background-image:url('..\images\banner.jpg');
    background-image:url('..\..\images\banner.jpg');

    I'd be very grateful if someone is willing to help me fix my issue!
    Thanks!!!

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    looks fine, you probably need to show more or it's an environment issue, like it's not on your webserver or you are viewing it locally or it missing or something, there are other possibilities but your syntax appears fine.
    what element are you applying this background image to?
    does it have enough height and width to display the image?

  • #3
    Banned
    Join Date
    Oct 2012
    Posts
    81
    Thanks
    0
    Thanked 4 Times in 4 Posts
    The relative path to your image in your css needs to be relative to the folder the css file is in, which you have and so that is not your problem.

    There are many possibilities as to why your image is not appearing.

    How are you linking your external stylesheet to your html file?

    Have you some embedded css in your html file stopping the bg image from appearing?

    etc

    etc

    etc

    Post your actual code so people can see what is going on.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •