locked
"/images" root directory access linking RRS feed

  • Question

  • User4339705 posted

    Occasionally I make a simple holding site on a project using just html that contains /css and /images folders in the root directory.  The css file located at "/css/style.css" will refer to images using "/images/myImg.jpg" for example.  This works fine on the web server at the address http://myserver/.  For development purposes, is it possible to configure the project to treat "/" as "~/" or and equivalent project root?

    This has just quirked my interest and I've be very grateful for any pointers.  Thanks for your time!

    Thursday, March 14, 2013 7:18 AM

Answers

  • User551462331 posted

    while referring resource files (image ect) from css, u can simply do /images/iagename.jpg

    here, first forward slash starts from root only... if css and image files are structured like this

    CSS

       -> style.css

    image

      -> image1.jpeg

    then , u can also refer image file from style.css as

    ../image/image1.jpg

    the strating dots indicate the path starting from one step level back. Also, note that the image paths in css are relative to the aspx page from where css is referred

    hope this helps...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 14, 2013 7:28 AM

All replies

  • User551462331 posted

    while referring resource files (image ect) from css, u can simply do /images/iagename.jpg

    here, first forward slash starts from root only... if css and image files are structured like this

    CSS

       -> style.css

    image

      -> image1.jpeg

    then , u can also refer image file from style.css as

    ../image/image1.jpg

    the strating dots indicate the path starting from one step level back. Also, note that the image paths in css are relative to the aspx page from where css is referred

    hope this helps...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 14, 2013 7:28 AM
  • User-760709272 posted

    add the runat="server" attribute to your <link> tag and you can use "~/css/style.css" as the src

    Thursday, March 14, 2013 7:28 AM