ruby-on-rails - 你如何让这个 div 环绕图像链接?

标签 ruby-on-rails css ruby ruby-on-rails-3 positioning

我有这个图片链接:

<%= link_to image_tag(comment.user.profile.photo.url(:tiny)), profile_path(comment.user.profile), :class => "comment_image" %>

我想包装一个包含 1. 文本和 2. 带有链接和图像链接周围文本的列表的 div。我希望图像位于左侧,而 div 位于图像的右侧。

enter image description here

最佳答案

假设您不需要 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/

相关文章:

ruby-on-rails - 类型错误 : wrong argument type String (expected Module)

ruby-on-rails - "$"字符在 Ruby 中是什么意思?

ruby-on-rails - 使用 NSURL 使用 JSON 在 Rails 服务器上创建新帖子时重复参数

css - 图像 - 全高,可使用 CSS 缩放

jquery - 如何隐藏/删除基于 Bootstrap 媒体查询断点的类?

ruby - 对数组使用散列选择

ruby-on-rails - `require' : cannot load such file -- rack/cache/entity_store (LoadError)

ruby-on-rails - 什么? ? ruby 的意思

ruby-on-rails - RVM 说它使用的是 2.7.3,但 ubuntu 说我使用的是 2.7.0

html - 如何编码这一部分,知道吗?