为css指定基本网址 [英] Specifying base url for css

查看:66
本文介绍了为css指定基本网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不拆分一个长的css文件。我把较小的css文件放在 styles 目录下。

I had to split up a long css file. I put the smaller css files within a styles directory.

现在我必须更新urls一个级别与 ../ 符号。

Now I have to update the the urls to go up one level with the ../ notation.

无论如何指定从其加载资产的基本URL像HTML中的基本标记,但使用CSS?

Is there anyway to specify the base URL from which to load assets like with the base tag in HTML, but with CSS?

推荐答案

不,我建议将CSS图像放在至少与CSS文件相同的级别,以便您不需要在路径中向后。例如。用于CSS文件的 / css 文件夹和用于CSS图像的 / css / images 文件夹。然后,您可以始终使用CSS图像的 url('images / name.ext')。这样,你可以放置根 / css 文件夹几乎无处不在的图像URL。

No, there isn't. I suggest to place the CSS images in at least the same level as the CSS file so that you don't need to go backwards in the path. E.g. /css folder for CSS files and /css/images folder for CSS images. Then you can consistently use url('images/name.ext') for CSS images. This way you can place the root /css folder practically everywhere without fiddling with the image URL's.

这篇关于为css指定基本网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆