如何使HTML与图片链接? [英] How to make a picture link with HTML?

查看:95
本文介绍了如何使HTML与图片链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < a href ='feed.php'> < img src =C:\xampp\htdocs\Project\Icons\Feed.png/>< / a> 

但是我的网页上没有图片,为什么?

(我目前只在本地使用我的页面!)

解决方案

这是因为您(正在尝试)使用本地文件引用。



使用相对路径



 < a href ='feed.php'>< img src =file:/// C:/ xampp / htdocs / Project / Icons / Feed .PNG/>< / A> 

请注意,如果您打算使用'online',它将因LOCAL参考而失败。



如果您通过网络服务器加载页面,您应该使用:

 < a href ='feed.php'>< img src =/ Icons / Feed.png/>< / a> 



 < a href ='feed.php'>< img src =http://yoursite.local/Icons/Feed.png/>< / a> 

或者图片的路径。

我宁愿使用相对路径(第一个),但它使您能够将页面移动到另一个域,而不会造成链接/图像中断。


I have made a picture link with this code snip:

<a href='feed.php'><img src="C:\xampp\htdocs\Project\Icons\Feed.png"/></a>

But no picture appears on my page, why?

(I'm currently only using my page locally!)

解决方案

It's because you (are trying to) use a local file reference.

Either use the relative path

or

<a href='feed.php'><img src="file:///C:/xampp/htdocs/Project/Icons/Feed.png"/></a>

Please be aware that if you plan to use this 'online' it will fail because of the LOCAL reference.

If you load the page through your webserver you should use:

<a href='feed.php'><img src="/Icons/Feed.png"/></a>

Or

<a href='feed.php'><img src="http://yoursite.local/Icons/Feed.png"/></a>

Or whatever the path to the image is.

I would prefer the relative path (the first) though which enables you to move your page to another domain without your links / images breaking.

这篇关于如何使HTML与图片链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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