Solved

How can I accurately reference my stylesheet?

Posted on 2015-01-14
3
61 Views
Last Modified: 2015-01-14
Here's the way my site's organization looks:

root
     css directory
     images directory
     app folder 1
     app folder 2

In my app folder, I'm referring to my stylesheet.css located in my css directory like this:       

<link href="../css/new_style.css" rel="stylesheet" type="text/css" />

Works great! All my fonts, margins, divs - everything is fine. The problem, however, is that none of my images show up because I'll have a background image in my stylesheet referenced as:

background-image: url(../images/background.jpg);

But because I'm sitting in my "app folder 1" directory, that URL doesn't work.

I realize I could probably change the URLs of my background images to an absolute value rather than a relative one, but it seems I saw a technique using "_DIR_" that remedies all of this.

I might be wrong, but I wanted to see if there was a way to code the reference to my stylesheet.css where any image url was handled correctly.

Thoughts?
0
Comment
Question by:brucegust
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40549808
Yes.  Just use...

background-image: url(/images/background.jpg);

The single slash makes it relative to the web root.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40549911
Uhm.... Why is this posted in the PHP topic?  It has zero to do with PHP.

Cd&
0
 

Author Comment

by:brucegust
ID: 40549934
Got it!

Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question