Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How can I accurately reference my stylesheet?

Posted on 2015-01-14
3
Medium Priority
?
66 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

618 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