hi, i''ve been through the rails apis and searched through past rails discussion, but i haven''t managed to find a way of aligning images with the image_tag() method. ideally i''d like to write something like image_tag("image.gif", :align => ''absmiddle'') to position the image vertically in the middle of some text. thanks luke
Hi Luke,> i''ve been through the rails apis and searched through past rails discussion, > but i haven''t managed to find a way of aligning images with the image_tag() > method. > > ideally i''d like to write something like > > image_tag("image.gif", :align => ''absmiddle'') > > to position the image vertically in the middle of some text.It''s a typical thing, you should do from CSS, not from HTML. If you just want to align this image, attach a class to it. Bye, Andras
Hi, the right way to do this is probably using css (style="vertical-align:middle"). Ciao, Björn -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of luke Sent: Wednesday, August 31, 2005 3:30 AM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails] image_tag :align => ''absmiddle'' ? hi, i''ve been through the rails apis and searched through past rails discussion, but i haven''t managed to find a way of aligning images with the image_tag() method. ideally i''d like to write something like image_tag("image.gif", :align => ''absmiddle'') to position the image vertically in the middle of some text. thanks luke _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hi Andras, Thanks for that. I''ve struck a problem with that solution, though hopefully you can help with this as well. The image is being used to indicate when an Ajax action is underway. So the image starts off with :style => ''display:none'' If I replace that with :style => ''myclass'' then it''s visible right from the start (before it''s intended to be visible). I could wrap the image_tag() method with a <div>, but is there a Rails way of passing the alignment class to the image through the link_to_remote() method for the Ajax? ps) I think having :align => ''center/left/right/absmiddle/etc.'' would be cool. Luke <%= image_tag("loading.gif", :id => ''search-indicator'' + msg.date, :style => ''display:none'') -%> ----- Original Message ----- From: "BÁRTHÁZI András" <andras-UUlgSIbigNGT9ig0jae3mg@public.gmane.org> To: "luke" <lduncalfe-ZKwmMI9HCDA@public.gmane.org>; <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Thursday, September 01, 2005 4:00 AM Subject: Re: [Rails] image_tag :align => ''absmiddle'' ? | Hi Luke, | | > i''ve been through the rails apis and searched through past rails discussion, | > but i haven''t managed to find a way of aligning images with the image_tag() | > method. | > | > ideally i''d like to write something like | > | > image_tag("image.gif", :align => ''absmiddle'') | > | > to position the image vertically in the middle of some text. | | It''s a typical thing, you should do from CSS, not from HTML. If you just | want to align this image, attach a class to it. | | Bye, | Andras |
luke wrote:> Hi Andras, > > Thanks for that. I''ve struck a problem with that solution, though hopefully you > can help with this as well. The image is being used to indicate when an Ajax > action is underway. So the image starts off with > > :style => ''display:none'' > > If I replace that with > > :style => ''myclass''What about: :class => ''myclass'' I haven''t tried this myself. Check the docs to see what to do to dictate a class if that doesn''t work.> > then it''s visible right from the start (before it''s intended to be visible). I > could wrap the image_tag() method with a <div>, but is there a Rails way of > passing the alignment class to the image through the link_to_remote() method > for the Ajax? > > ps) I think having :align => ''center/left/right/absmiddle/etc.'' would be cool.I have to disagree. CSS was invented by a very very good reason. I think it is time you took the dive and checked it out. Sometimes change really *is* good.> > Luke > >Ronny
Hi Ronny, Thanks for your reply, I''ll see if that works. I can''t pass up the opportunity to also reply about CSS ... | > then it''s visible right from the start (before it''s intended to be visible). I | > could wrap the image_tag() method with a <div>, but is there a Rails way of | > passing the alignment class to the image through the link_to_remote() method | > for the Ajax? | > | > ps) I think having :align => ''center/left/right/absmiddle/etc.'' would be cool. | | I have to disagree. CSS was invented by a very very good reason. I think | it is time you took the dive and checked it out. Sometimes change really | *is* good. First, your assumption is that I was imagining an :align = > ''alignment'' tag to translate to HTML. Rails could also construct the alignment as a style="" attribute within the <img> tag. CSS declared within a tag has higher precedence over CSS formatting declared in a .css file. See http://www.w3.org/TR/REC-CSS1#cascading-order And as for change, I''ve been using CSS for around 5 years (and making websites for 11). Regards, Luke