img tag not working with relative path in src

后端 未结 5 1214
星月不相逢
星月不相逢 2020-12-17 16:00

This is not working:

\"Alternative

But this is working:



        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-17 16:42

    "../assets/images/image.jpg" -This means

    1. '../' go up one directory from where I am now
    2. find the 'assets/' folder
    3. find the 'images' folder
    4. find the 'image.jpg' file.

    That relative link will only work if your page is in a subfolder in

    "http://localhost/abc/def/geh/"

    If the location of your page really is

    "localhost/asdf/asdf/asdf/asdf/index.php"

    (which seems ridiculous) to get to the assets folder relatively you would have to go all the way to the root.

    '../../../../abc/deh/geh/assets/images/image.jpg;

    Alternatively you could use a base tag in your head tag to make the URL in the actual src attribute more friendly.

提交回复
热议问题