How to go up a level in the src path of a URL in HTML?

后端 未结 6 1285
北荒
北荒 2020-11-28 02:06

I am storing style sheets in {root}/styles while images in {root}/images for a website. How do I give the path in the style sheets to go look in the images directory for th

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 02:35

    Supposing you have the following file structure:

    -css
      --index.css
    -images
      --image1.png
      --image2.png
      --image3.png
    

    In CSS you can access image1, for example, using the line ../images/image1.png.

    NOTE: If you are using Chrome, it may doesn't work and you will get an error that the file could not be found. I had the same problem, so I just deleted the entire cache history from chrome and it worked.

提交回复
热议问题