Creating CSS url () relative to a document

When it comes to CSS, the following rule applies:

Partial URLs are interpreted relative to the source of the style sheet,
not relative to the document.

But here is my problem:

I have different sites that use the same CSS file. Although they use the same layout, the actual images of the CSS links are different for each of them.

Exemple:

#header {
width: 960px;
height: 200px;
background: url(/images/header.png);
}

Each domain has its own "images" folder and its own "header.png", which I would like CSS to reference. Currently, it behaves as it should, and tries to find the png file in the domain where the CSS is located. I want him to get the png file from the domain where the CSS file was called.

I use a "link" for style sheets because "@import" breaks progressive rendering in IE.

Any suggestion or workarounds?

+5
6

, png , CSS.

URL- . www.example1.com /style/sheet.css , , http://www.example1.com/style/sheet.css, www.example2.com http://www.example2.com/style/sheet.css.

, , , , ( , ). Alias CSS.

, , - URL, background-image, , , .

+2

CSS - script.

example1.com/global.css - CSS

example2.com/global.css.php - PHP script, global.css example1.com

script ,

<?php
readfile('http://example1.com/global.css');
?>

, .

+2

- CSS css

#header {
   background: url(images/header.png);
}

, , , .

+1

, , - , :

/* domain specific images */
#header {
    background-image: url(/images/header.png);
}
0

, php , ""?

:

#header {
background: url('.$domain.'/images/header.png);
}

, , , , - ! , , IE?

0

,

#header {
background: url('/images/header.png');
}

#header {
background: url('../images/header.png');
}

, ( css).

EDIT:

, ?

0
source

All Articles