图片的CSS相对网址

编程入门 行业动态 更新时间:2024-10-16 02:22:09
本文介绍了图片的CSS相对网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在本地主机上进行开发- localhost/mysite ,其中具有以下目录结构:

I am developing on my localhost - localhost/mysite, and within that I have the following directory structure:

-assets --css ---styles.css --images ---background.png

在styles.css文件中,我将得到以下内容,在localhost上可以正常使用

Within the styles.css file, I would have something the following, which works fine on localhost

background-image: url(../images/background.png);

但是,实时服务器在一个子域上运行- test.liveserver .这意味着css规则必须进行如下更改:

However, the live server works off a subdomain - test.liveserver. This means that the css rule has to change as follows:

background-image: url(/assets/images/loginlogo.png);

不确定要解决此问题的最佳方法吗?

Not sure on the best way to get around this?

推荐答案

通过提供的目录树,您不必更改路径.

With the directory tree you are providing you don't have to change your path.

..表示CSS文件的父目录,因此暗指assets/目录.

.. means the parent directory of the CSS file so the assets/ directory is implied.

更多推荐

图片的CSS相对网址

本文发布于:2023-11-02 00:14:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550813.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网址   图片   CSS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!