CSS root directory

前端 未结 6 1465
小鲜肉
小鲜肉 2020-12-13 00:01

I have a style sheet where I include background images.

background: url(../Images/myImage.png);

problem is, pages from different directorie

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 00:36

    This problem that the "../" means step up (parent folder) link "../images/img.png" will not work because when you are using ajax like data passing to the web site from the server.

    What you have to do is point the image location to root with "./" then the second folder (in this case the second folder is "images")

    url("./images/img.png")
    

    if you have folders like this

    root -> content -> images

    then you use url("./content/images/img.png"), remember your image will not visible in the editor window but when it passed to the browser using ajax it will display.

提交回复
热议问题