开发者

CSS directory issue?

Let's say if I link to a background img in a css file url(img/bg.png), and the css file is at http://example.com/test/style.css and the img file is at http://example.com/test/img/bg.png

However I browse the page at http://example.com/index.html and i like to the css file via <link rel='stylesheet' type='text/css' hr开发者_StackOverflow中文版ef='test/style.css' /> with the base set to <base href="http://example.com" />

Would the css file work?


This should work

index.html includes test/style.css , which is a valid link

AND

style.css has /test/ as root so img/bg.png is also valid link

NOTE: as a general convention it's good to include ./ when referring to current directory best choice is to refer images like ./test/bg.png from your css file


See this answer: Using relative URL in CSS file, what location is it relative to?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜