Results 1 to 4 of 4

Thread: cant access picture

  1. #1
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default cant access picture

    hi,
    i am using a picture as a button, the pathe of the pictur is lik this:-

    mydir > img > picture.gif (this is the path of image file)

    mydir > css > style.css (this is the path of css files)


    my css file is lying in diff directory and image in diff dir... so how i can access it by using relative path only?

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    ../
    or
    ./
    not sure off topp of head fiddle with that though or post link

  3. #3
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Code:
    .example{
    background:url('../img/picture.gif');
    }

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Just a fine point here, but unless we are talking about a background image, as is generally not the case with an input of the type="image", the image must be hard coded as the src attribute of the input. If you do have an input of the type="button" it can have a css background image associated with it from the stylesheet, but this may not always appear as expected on the button, different browsers may treat it quite differently.

    In general, relative paths in the stylesheet are relative to the stylesheet, not to the page on which the style gets used. As far as I know, the only exception is with IE proprietary 'styles' like .htc behaviors and filters which are also part javascript and must be relative to the page that uses them.

    In all cases though, the absolute or network paths may be used, and often cause less confusion.

    An absolute path includes the full URL (href if you will):

    Code:
    http://www.domain.com/path/filename.ext
    and a network path uses the / to denote the root of the domain (on a local system though this will be the root of the drive):

    Code:
    /path/filename.ext
    Last edited by jscheuer1; 10-11-2009 at 03:17 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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