Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Get device physical size using CSS3

Get device physical size using CSS3

Problem

I have an HTML5 page using CSS3 and SVG graphics in development. I tried using media queries to enlarge the SVG graphics when the device pixel ratio is 1.5 or 2. This works fine. Now I view my page on a small device like the Motorolla Xoom. The reported ratio is 1. This means the Xoom displays everything quite small as compared to a regular monitor. The most annoying part is that it looks great in landscape mode, but in portrait mode the full page is resized to fit in the same width. The ratio number does not change at this point.

I did try using something like 'width: 3in;' but again, it was only the correct size in landscape.

Ultimately, I'd like to use some ratio of device size vs pixel size, and scale everything this way. Is this possible?

Problem courtesy of: Paul

Solution

My issue was that my graphics were never rendered again when orientation was changed. When I hit refresh again, all is coming up as expected. This was an issue that existed somewhere between my keyboard and my chair. The media queries are in fact working, I just need to rerender some stuff upon orientation change.

Solution courtesy of: Paul

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

Get device physical size using CSS3

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×