如何将图像转换为 Rails 中的链接? [英] How do I turn an image into a link in Rails?
本文介绍了如何将图像转换为 Rails 中的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想在图像上做一个简单的链接.
I just want to do a simple link on an image.
<a href="http://www.mysite.com"><img src="path/to/image.png"/></a>
你如何使用 link_to rails 标签来做到这一点?
How do you do this with a link_to rails tag?
推荐答案
使用 image_tag
作为 link_to
的内容.
Use an image_tag
for the contents of the link_to
.
link_to image_tag("path/to/image.png"), "http://www.mysite.com/"
这篇关于如何将图像转换为 Rails 中的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文