I have a CSS file using CSS3PIE behavioral script, so that IE8 will support my files, however, I was wondering if there is any way to make the behavioral URL relative to the CSS file instead of relative to the HTML file. Is there any way to do this?
-
No, Also you can't link to behavioral cross domain therefore no google-code for hosting either. Yeah its kinda frustrating. – Lime Jun 20 '11 at 21:32
-
Thanks lime, and yes it is very frustrating CSS3 is very cool but hard to implement by fighting with all the browsers, this is the only solution I could think of. Fortunately only one HTML file needs that file, at least right now. – Travis Pessetto Jun 21 '11 at 04:28
-
I can't wait until google frame takes hold like flash has as a plugin. – Lime Jun 21 '11 at 04:31
3 Answers
You could use a path with a preceding slash (from the root of the domain), similar to this:
behavior: url(/css/PIE.htc);
which should work as expected.
Or, you could use the PIE.js version: http://css3pie.com/documentation/pie-js/
Advantages of the JS version - Referencing the PIE.js file via a relative path is simpler ..
But, there are a lot of downsides to PIE.js. Tread carefully.

- 224,678
- 48
- 389
- 349
Another other approach is to use a server-side technology to find the root for you. I use this technique because I tend to develop sites in virtual directories, rather that at the local domain root.
Major downside is that this needs to be done in-code, rather than in a distinct CSS file.
.NET example:
<!--[if lt IE 7]>
<style>
.foo
{
behavior: url(<%= ResolveUrl("~/") %>/js/libs/PIE.htc)
}
</style>
<![endif]-->

- 10,937
- 7
- 33
- 59
Keep in mind that if your site has HTTPS and non-HTTPS content you may want to use a double slash to keep it protocol agnostic: http://paulirish.com/2010/the-protocol-relative-url/
This has the one downside of IE8 grabbing both versions of the file.

- 21
- 1
- 5