Sunday, 8 September 2013

image overlay in RoR

image overlay in RoR

I want to overlay one image on top of another in RoR.
Doing so in plain html is easy (from
http://stackoverflow.com/a/1997397/1760830):
<div style="position: relative; left: 0; top: 0;">
<img src="a.jpg" style="position: relative; top: 0; left: 0;"/>
<img src="b.jpg" style="position: absolute; top: 30; left: 70;"/>
</div>
This code works for me when I put it in a separate file.html. Then in
Rails I do:
<div style="position: relative; left: 0; top: 0">
<%= image_tag "a.jpg", :style => "position:relative; top:0; left:0;" %>
<%= image_tag "b.jpg", :style => "position:absolute; top:30; left:70;
border:thick solid blue;" %>
</div>
but the second image is displayed next to the first one, without any
offset. The second image border is added to the code to check that the
style is actually passed on.
Any ideas why the Rails version doesn't work?
ruby 1.9.3, rails 3.2

No comments:

Post a Comment