我有这个图片链接:
<%= link_to image_tag(comment.user.profile.photo.url(:tiny)), profile_path(comment.user.profile), :class => "comment_image" %>
我想包装一个包含 1. 文本和 2. 带有链接和图像链接周围文本的列表的 div。我希望图像位于左侧,而 div 位于图像的右侧。
最佳答案
假设您不需要 link_to
帮助程序提供的任何高级功能,简单的答案是直接使用 anchor 标记。
<a href="<%= profile_path(comment.user.profile) %> class="comment_image">
<div>
Some stuff -- whatever
<%= image_tag(comment.user.profile.photo.url(:tiny)) %>
Some more stuff -- ya know...
</div>
</a>
关于ruby-on-rails - 你如何让这个 div 环绕图像链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5562180/