Solved

How can I accurately reference my stylesheet?

Posted on 2015-01-14
3
57 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 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
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
Comment Utility
Uhm.... Why is this posted in the PHP topic?  It has zero to do with PHP.

Cd&
0
 

Author Comment

by:brucegust
Comment Utility
Got it!

Thanks!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now