css @import external style sheet

2019-04-24 09:54发布

问题:

If it possible to use @import in a .css file to load a style sheet from another site? Specifically, I have a main style sheet for my site which loads in other (local) style sheets using @import. I'd also like to load in a jquery ui theme hosted by google, e.g.

@import "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css";

This does not seem to work - I wanted to check whether this is allowed before working out exactly where the problem is.

回答1:

That should work. Are you sure it is not loaded? What browsers does this happen in? Can you confirm using Firebug?

There is no mention of it not working in the w3 specs nor in the related MSDN Article (The latter applies to IE only of course).

According to those specs, adding url(...) around the address is optional, but try whether that yields better results.



标签: css import