AlanF
AlanF

Reputation: 1601

How to resize webpage depending on the device

Well does anyone know of a javascript that detects whether a user is using a mobile phone or a normal computer and then resizes the window to fit that device, if it cant be done with javascript does anyone know a way in which it can be done.

Thanks for any help that ye can give

Upvotes: 1

Views: 2161

Answers (2)

zSprawl
zSprawl

Reputation: 999

I use these:

/* Non-Retina */
@media screen and (-webkit-max-device-pixel-ratio: 1) {
}

/* Retina */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
}

/* iPhone Portrait */
@media screen and (max-device-width: 480px) and (orientation:portrait) {
} 

/* iPhone Landscape */
@media screen and (max-device-width: 480px) and (orientation:landscape) {
}

/* iPad Portrait */
@media screen and (min-device-width: 481px) and (orientation:portrait) {
}

/* iPad Landscape */
@media screen and (min-device-width: 481px) and (orientation:landscape) {
}

http://zsprawl.com/iOS/2012/03/css-for-iphone-ipad-and-retina-displays/

Upvotes: 0

user956584
user956584

Reputation: 5558

Nice article from smashing magazine

http://coding.smashingmagazine.com/2010/07/19/how-to-use-css3-media-queries-to-create-a-mobile-version-of-your-website/#more-50749

eq.

 @media only screen and (max-device-width: 480px) {
        // insert styling here… 
 }

Upvotes: 2

Related Questions