Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS root directory

Tags:

css

I have a style sheet where I include background images.

background: url(../Images/myImage.png); 

problem is, pages from different directories use this css!

My CSS files are in a CSS folder, images in an Image folder, and my html pages are in many different folders depending on their content and meaning to the website.

All my pages inherit this css as it is the MAIN theme.

The path used in the above example is a relative path. And obviously, this path only works for some of the pages. ALL i need is to link the images in the css from the ROOT folder. Therefore every path is correct no matter where the file is in the folder structure!

I have tried:

~/Images/myImage.png ./Images/myImage.png /Images/myImage.png Images/myImages.png 

I don't think a root folder selector exists... but I hope it does :/

like image 562
AlexMorley-Finch Avatar asked Aug 12 '11 09:08

AlexMorley-Finch


People also ask

Where is the root directory located?

How to find your store's root folder? In most cases, your store's root folder is located in the “home” folder. However, if you can't find it, please use the path “/sub_folder/site_root_folder” to access directly to your root directory.

What is your root directory?

In a computer file system, and primarily used in the Unix and Unix-like operating systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the trunk of a tree, as the starting point where all branches originate from.


1 Answers

/Images/myImage.png 

this has to be in root of your domain/subdomain

http://website.to/Images/myImage.png

and it will work

However, I think it would work like this, too

  • images
    • yourimage.png
  • styles
    • style.css

style.css:

body{     background: url(../images/yourimage.png); } 
like image 76
genesis Avatar answered Sep 22 '22 09:09

genesis