Home > Questions and Answers > General Questions

@media query (6)


03-12-2014 07:13 AM #1 freeflowexp (Member)
@media query

Hello,

I was following part 2 of caurmen's fantastic thread on Mobile LPs and was able to follow all of it.

I made media queries targeting various handsets. All of them worked except the one for the iphone 3gs. I targeted based on the screensize dimensions provided by the javascript ("320x396"), in particular the the height of 396px. I ran the website through browserstack, but the iphone 3gs did not respond. The text size remained the same.

Thinking it could've been a bug on browserstack I took the time to get hold of the handset which also spat out dimensions of 320x396 in the javascript. The actual handset also failed to respond.

My code has been placed in the style area as follows:

@media only screen and (orientationortrait)
and (max-height : 396px) {
.heading {font-size: 10pt;}
.benefits{font-size: 8pt; }
.important_info{font-size: 8pt;} }


Is there something wrong with the way I've written the code? Is there something else I have to target or take into account with the iphone 3GS model?

Thanks for your help!


03-12-2014 07:30 AM #2 zeno (Administrator)

Ugh I had the same issues with device testing and media queries - you get everything working fine and then one damn device bucks the trend. The following resources may be helpful:
http://caniuse.com/css-mediaqueries
http://css-tricks.com/logic-in-media-queries/
http://cssmediaqueries.com/target/

According to the latter link, to target the iPhone 3G you use:

Code:
@media screen and (device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)
Maybe a similar code will work for the 3GS

Tbh I just go for the blanket approach of making rules ad hoc for every annoying device that doesn't display as I want. CSS size be damned!


03-12-2014 08:31 AM #3 freeflowexp (Member)

Awesome zeno!

Will try all of them and report back on anything that's successful.


03-12-2014 10:37 AM #4 freeflowexp (Member)

okay great news the code worked with a slight change in the dimensions. So rather than using 320px and 480px in your example I had to stick with the dimensions spat out with the Javascript so it ended up being:

@media screen and (device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)

The issue however is that now the landscape orientation doesn't work. Any idea how to sort that out? It doesn't seem to respond to orientation: landscape.


03-12-2014 11:56 AM #5 zeno (Administrator)

Hmm dunno, try adding "and (orientation: portrait)" to one set of rules and a "and (orientation: landscape)" to another?


03-12-2014 12:30 PM #6 freeflowexp (Member)

yeah unfortunately tried that and it didn't seem to work. I think it's simply the model/software version which just doesn't respond to the orientation query. Thanks heaps for that!


Home > Questions and Answers > General Questions