I'm currently annoyed by my media queries to target smartphones. It's the first time I use media queries.
I've done a tablet version (768px) of a website, and a phone version (320px).
Note that theses screenshots are actually Firefox screenshots.
As you can see, these displays work fine when I resize my window on Firefox, IE, Webkit.
However, the display is wrong on my iPhone 3G and my Xperia X8.
Here are the results (left iPhone, right Xperia) :
As far as I know, both phones have a 480*320 pixels resolution.
So, why such results?
On the iPhone screen, the light brown rectangle on the header is supposed to be 300px width. Why is it so small?
And why is the tablet version loaded on the Xperia ?
I use these media queries on my CSS :
/* Tablets ----------- */
#media (min-width: 768px) and (max-width:1023px)
/* Phones */
#media (min-device-width: 320px) and (max-device-width:767px),
(min-width: 320px) and (max-width:767px)
I hope you'll can help me, I'm stuck on this issue since too much days.
Have you setup a proper viewport? Like:
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=2.0" />
Put that in your head tag.
Use proper media Queries to ensure the perfect rendering and responsiveness for smart phones and cross platforms. here is the link you can learn how to use media queries in right way. css tricks
Related
I need to open large screen view(e.g.screen width 1400px) in small screen . I had this problem for mobile, which was solved by using this meta <meta name="viewport" content="width=1220">. Related question RWD: Show Desktop version in mobile minified, without horizontal scroll
I can't use #media for smaller desktops as client wants the same sizes and appearance as in large screens. So is there a way to use this meta not only for mobile devices but for desktops too or you can advise another way? Thanks!
I have a phonegap based html app that I'd like to show on both desktop/ipad and mobile.
I was looking into media-queries but it seems pretty cumbersome that I need to specify min/max px. and do a separate media query for each type of mobile so for example iphone4, iphone5, iphone6, iphone6plus, etc because they have different sized screens.
What I want basically is to set up a css where I say, "for all mobile devices in landscape do this", and "for all mobile devices in portrait do this". I don't want to get into specifics about WHICH type of mobile device it is or fiddle around with specific screen dimensions. I don't even want the word "px" to appear in my media query basically.
Similarly I want to know if it's a tablet portrait/landscape.
And if it's a desktop.
Is there an easy way to do this with media queries?
You're correct in not wanting to create different layouts for every specific mobile device, as it will be an ever increasing list of devices it isn't robust at all. However making the distinction between desktop and mobile also isn't easy. Just think about the screen resolution of a tablet versus a netbook pc, they are almost alike.
In my opinion the best way to design your breakpoints is to start with a mobile view and to keep expanding the screen size until you think that the design doesn't work anymore. At that point you should include a breakpoint and update your design (perhaps add a sidebar, show an expanded menu etc).
So unfortunately I think that there isn't an easy way to distinguish between mobile an desktop devices, the only easy option would be to find a pixel based breakpoint (bootstrap uses 992px) from which your desktop design should apply.
To make the distinction between portrait and landscape mode you can use #media screen and (orientation: portrait) and #media screen and (orientation: landscape).
For example you could use something like this:
.container {
/* mobile devices */
}
#media screen and (orientation: landscape) {
/* mobile devices in landscape */
}
#media screen and (orientation: landscape) and (min-width: 992px) {
/* desktop devices */
}
I have a problem with automatically changing resolution on Blackberry Playbook 7" and Blackberry Q10 (720 x 720) on some pages on a website I'm currently working on. The problem is illustrated on screenshot (little bit of explanation: on pages with Nivo slider included, everything is smaller than on other pages of the same website). Screenshots are taken on BB Playbook tablet.
that's the media query for vertical display:
#media screen and (orientation: portrait)
On BB Q10 even stranger thing happens, because when page with Nivo slider is being displayed, the device takes different media query than it should. BB Q10 is 720 x 720 px screen resolution, so it should go for a media query:
#media screen and (min-width: 530px) and (max-width: 860px) and (orientation: landscape)
but pages with Nivo Slider are in fact being displayed with media query:
#media screen and (min-width: 861px) and (max-width: 1120px) and (orientation: landscape)
Am I doing something wrong or is it just a device?
screenshot
website
In your site, it looks like you're missing the viewport meta tag in the head.
<meta name="viewport" content="width=device-width, initial-scale=1">
You can find a good discussion on it on the Mozilla Developer Network. There's also a fairly exhaustive explanation at quirksmode.I'm guessing that missing tag is what's causing the difference.
Unfortunately mobile phones have such high screen resolutions that my website comes it far to small. It adapts perfectly when zoomed in on a desktop browser but unfortunately on mobile browser the webpage viewport size does not actually change once zoomed. To try and solve this I have already gotten a script that detects a mobile user agent and then sets the body width to 500px, this looks about the perfect width but unfortunately the mobile browser does not set its viewport to 500 even after I set the meta for viewport 500 and this results in my webpage rendering in the corner of the browser. Once zoomed in it looks fine though but that is not what I want. My site is in some way similar to nokia.com and I want it to behave in the same way on a mobile client.
Can someone please tell me what the correct procedure is for doing something like this because I am in no way a proper web developer, I am just doing this to learn.
Here is my meta:
<meta name="viewport" content="width=500,initial-scale=1,maximum-scale=1,user-scalable=no">
You need to write conditional CSS rules for smaller browser sizes.
One example:
#media screen and (min-width: 768px) {
.item1{}
.item2{}
}
Here is a site I just found through a quick google search that should be able to get you started at least. http://www.conditional-css.com/usage
Good luck with your learning!
It is better to use #media queries (available is css3)
Something like:
#media only screen and (min-device-width : 320px) and (max-device-width : 480px) /* You can change this value per your requirements */
{
/* Your custom styles for mobile device */
}
Try this
<meta name="viewport" content="width=device-width", maximum-scale=1.0, minimum-scale=1.0, initial-scale=1.0 />
and use the media query to target all the screen size
http://blog.teamtreehouse.com/thinking-ahead-css-device-adaptation-with-viewport
Hope this helps you
Finally solved it! It seems the reason I was having so much trouble is because the mobile device I was testing in was a Windows Phone 8 device and apparently WP8 does not really respond well to the viewport meta tag. This is easily solved by the addition of a MobileOptimized meta tag.
I'm looking for the correct CSS media query to target all phones (not tablets and larger) including 1080 phones such as the Sony Xperia Z.
Right now I'm using:
<link href='style/mobile.css' rel='stylesheet' type='text/css' media='screen and (max-device-width: 767px)' />
That works for most devices, but in the Android Firefox Browser (not Chrome though strangely) the Xperia Z just gets the desktop site only.
I've tried searching but it seems no one is talking about these new very high-res phones, is there a new standard I should be adhering to?
Use max-width instead of max-device-width to target CSS pixels.
Do not forget viewport meta. Small devices with lots of pixel will still have a low CSS pixel count so it will just work.
You can combine the width with resolution in your media query.
#media screen and (max-device-width: 767px) and (min-resolution: 300dpi) { … }
I don't think you'll find what you need in media queries. Phones and tablets have a big crossover in resolutions.
Here are the media features you can query according to the w3c...
http://www.w3.org/TR/css3-mediaqueries/#media1
... none seem to be what you're looking for.
Unfortunately I don't know if a great way to deal with this, even the user-agent is of little help.