#1
  1. :(){ :|:&};:
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Germany
    Posts
    297
    Rep Power
    12

    CSS: Background Image Path


    Hi there

    I have a probelm linking to a background image using CSS. I am using this line:

    background-image:url('/path/back01.gif');

    "path" is the direct path underneath localhost. The picture shows up when I am trying the view it with my browser (http://localhost/path/back01.gif) . But in my PHP File it doesn't. I am using the direct path because the paths of my PHP File are a bit confusing - so I thought it would be easier, but it doesn't work. I am having a php file, that includes other php files with functions, and these functions include the stylesheet:

    index.php
    |-include
    |+-functions.php
    ||-stylesheet.css
    |-images
    |+-back01.gif


    index.php should show the background image, the stylesheet links to the image and the stylesheet is printed into the index.php by the functions, I mean it is linked.

    Do I have to specify the path for the background-image option so that I recognizes it that it is a direct path?
    Thanks for taking your time
    regards >_<

    ws. fgeller.de
    em. felix@fgeller.de
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    249
    Rep Power
    12
    How are you linking to the stylesheet? Probably the php server cant find your css file.


    http://galileo.spaceports.com/~ibidris/
  4. #3
  5. Retired
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Location
    Finland
    Posts
    9,143
    Rep Power
    2493
    The path should be relative to where the css file calling the image is.


    Lets say you have the set up:

    http://localhost/path/index.php
    http://localhost/path/images/back01.gif
    http://localhost/path/styles/stylesheet.css

    If you are importing or calling a CCS in index.php you path in the css to the image would be:

    background-image:url('../back01.gif');

    Alternatively, you could use full URL.

    HTH

    Jamie

    Cheers,
    Jamie

    >_ skiFFie ? | Twitter

    __________________

    Let the might of your compassion arise to bring a quick end
    to the flowing stream of the blood and tears .....
    Please hear my anguished words of truth.

    __________________
  6. #4
  7. :(){ :|:&};:
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Germany
    Posts
    297
    Rep Power
    12
    Hmm I am pretty sure that my Server can find the CSS file, as nothing would be formatted on the whole page without it.

    jabba_29:
    The direct and full path would be the "safer" way. By that I mean that it should work 100% right? I was using the way that you ary saying, relative to the location of the css stylesheet not the php file, but still it didn't work. But as I said the direct path shows up the picture, how can I put the full path into the url? as url("http://localhost/path/images/back01.gif");
    doesn't work.
    regards >_<

    ws. fgeller.de
    em. felix@fgeller.de

IMN logo majestic logo threadwatch logo seochat tools logo