What''s the easiest or best way to determine the screen size from within a controller or view in Rails? My "divs" look great at 1280x800, but not so hot on 800x600. I want to dynamically alter the layout based on the resolution. Any hints regarding screen size or alternate ways of handling this issue would be appreciated. Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060419/f01ed5dd/attachment.html
I would suggest not trying to find out, but instead learning how to design your CSS stylesheets to be independant of screen size. I''m not really good at layout design, but the book "Cascading Style Sheets (3rd ed)" by Hakon Wium Lie and Bert Bos was helpful to me. Maybe try here: http://www.sitepoint.com/article/top-ten-css-tricks Google may help find good tutorials. Good Luck, Sean Nathan Leach wrote:> What''s the easiest or best way to determine the screen size from within > a controller or view in Rails? My "divs" look great at 1280x800, but > not so hot on 800x600. I want to dynamically alter the layout based on > the resolution. Any hints regarding screen size or alternate ways of > handling this issue would be appreciated. > > Thanks!-- Posted via http://www.ruby-forum.com/.
There isn''t a reliable way to do this. You''d do it with javascript to get the objects width and height, but just about every browser and browser revision has changed the way this is accomplished. Look into javascript and see what you can find. Good luck with it On 4/19/06, sean lynch <sean.seanlynch@gmail.com> wrote:> > I would suggest not trying to find out, but instead learning how to > design your CSS stylesheets to be independant of screen size. > > I''m not really good at layout design, but the book "Cascading Style > Sheets (3rd ed)" by Hakon Wium Lie and Bert Bos was helpful to me. > > Maybe try here: > http://www.sitepoint.com/article/top-ten-css-tricks > > Google may help find good tutorials. > > Good Luck, > > Sean > > Nathan Leach wrote: > > What''s the easiest or best way to determine the screen size from within > > a controller or view in Rails? My "divs" look great at 1280x800, but > > not so hot on 800x600. I want to dynamically alter the layout based on > > the resolution. Any hints regarding screen size or alternate ways of > > handling this issue would be appreciated. > > > > Thanks! > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- -Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060419/45e23ae1/attachment.html
I was thinking about this too. Sometimes you need to know the screen size so that your site can look its best at all resolutions. I would recommend having one CSS file per screen size, and loading the appropriate one using JavaScript. Dave Shea mentions this approach near the end of this podcast: http://www.thinkvitamin.com/interviews/css/ dave-shea/. He mentions a JS library that does this for him, but I don''t have the link. HTH. On Wednesday, April 19, 2006, at 10:00 PM, sean lynch wrote:>I would suggest not trying to find out, but instead learning how to >design your CSS stylesheets to be independant of screen size. > >I''m not really good at layout design, but the book "Cascading Style >Sheets (3rd ed)" by Hakon Wium Lie and Bert Bos was helpful to me. > >Maybe try here: >http://www.sitepoint.com/article/top-ten-css-tricks > >Google may help find good tutorials. > >Good Luck, > >Sean > >Nathan Leach wrote: >> What''s the easiest or best way to determine the screen size from within >> a controller or view in Rails? My "divs" look great at 1280x800, but >> not so hot on 800x600. I want to dynamically alter the layout based on >> the resolution. Any hints regarding screen size or alternate ways of >> handling this issue would be appreciated. >> >> Thanks! > > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsCheers! --Dave Teare http://devlists.com - Email list management http://palmsphere.com - Apps for your hand-held -- Posted with http://DevLists.com. Sign up and save your mailbox.