Image_tag Positioning/Alignment

Hi:

I searched the forum before posting and could not find any help on how to position an image using image_tag ('image_name').

I have an image in a div, and I need to move it to the right.

How do I this? I have this code:

<div id="mainDivright"><%= image_tag ('name.gif'), :options => {:align=>"right" } %></div>

I even tried this:

<div align="right" id="mainDivright"><%= image_tag ('name.gif') %></

and it does not seem to work.

Thanks in advance for taking the time to answer.

How would you do that on plain HTML? you should check your generated HTML and compare it wth your plain HTML solution. image_tag does nothing but generate an HTML <img /> tag with the attributes you give as parameters. Check the rdoc for image_tag to see what are those parameters.

add to your css stylesheet:

#mainDivright { float: right; }

Just a little more elaboration...

I'm assuming your view contains:

<%= image_tag ('name.gif'), id="mainDivright" %>

If you check the html produced using firebug you should see something like:

<img id="mainDivright" src=...

The css stylesheet can key off this id.