Forum: Ruby on Rails Determining screen size and/or resolution?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B287416096bb24ccaaedef43b0b1921b?d=identicon&s=25 Nathan Leach (Guest)
on 2006-04-19 21:24
(Received via mailing list)
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!
8716cce9a7b721786e5425b8cc1f9951?d=identicon&s=25 sean lynch (Guest)
on 2006-04-19 22:00
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!
6de7ba135902e959c4c731f6afa0f40d?d=identicon&s=25 Matt Ramos (Guest)
on 2006-04-19 22:14
(Received via mailing list)
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
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Dave Teare (Guest)
on 2006-04-19 22:26
(Received via mailing list)
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:
>
>>
>> Thanks!
>
>
>--
>Posted via http://www.ruby-forum.com/.
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails


Cheers!
--Dave Teare
http://devlists.com - Email list management
http://palmsphere.com - Apps for your hand-held
This topic is locked and can not be replied to.