How do you get this div to wrap around an image link?
I have this image link:
<%= link_to image_tag(comment.user.profile.photo.url(:tiny)), profile_path(comment.user.profile), :class => "comment_image" %>
and I want to wrap a div co开发者_运维知识库ntaining 1. text and 2. a list with a link and text around that image link. I want the image to be on the left, and the div to be on the right wrapping around the image.
Assuming you don't need any of the fancier features offered by the link_to
helper, the easy answer is to just use an anchor tag directly.
<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>
would you care if i posted it in HAML(same thing as erb just without the <% %>
and closing tags:(sort of pseudo code for html)
%ul
%li
= link_to image_tag(comment.user.profile.photo.url(:tiny)), profile_path(comment.user.profile), :class => "comment_image"
%div.user-comments
comment
username etc
%li
rinse-repeat
AND dont forget to clear your float on the li!
then in your css, just float comment_image and user-comments left.
精彩评论