I've got my visitor portal setup for 3 types of devices: mobile (less than 800px width), low-res desktop and hi-res desktop, like this:
<link media="only screen and (min-width: 801px) and (max-height: 899px)" href="..." rel="stylesheet" type="text/css">
<link media="only screen and (min-width: 801px) and (min-height: 900px)" href="..." type="text/css">
<link media="only screen and (max-width: 800px)" href="..." rel="stylesheet" type="text/css">
All this works rather well but with the iPad Pro portrait, the width of the screen is less than 800px but the stylesheet that's selected is the low-res desktop. What do I need to change to make it work?
Edit (to clarify the problem)
When I do something like this
<link media="only screen and (min-width: 801px) and (max-height: 899px)" href="..." rel="stylesheet" type="text/css">
<link media="only screen and (min-width: 801px) and (min-height: 900px)" href="..." rel="stylesheet" type="text/css">
<link media ="only screen and (max-width: 800px),
only screen and (max-device-width:1024px) and (-webkit-min-device-pixel-ratio:1.1) and (orientation:portrait),
only screen and (max-device-height:1366px) and (-webkit-min-device-pixel-ratio:1.1) and (orientation:landscape)"
href="..." rel ="stylesheet" type="text/css">
The problem is that the styles get mixed-up at different resolutions. I'm looking to make it work so that only one stylesheet is active at anytime.
iPad Media Queries
iPad Media Queries (All generations - including iPad mini)
iPad in portrait & landscape
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) { /* STYLES GO HERE */}
iPad in landscape
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) { /* STYLES GO HERE */}
iPad in portrait
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) { /* STYLES GO HERE */ }
To know more about device media queries, please visit Stephen.io/mediaqueries
Source credits to http://stephen.io/mediaqueries/
Hope this may help you.
Thank you
So, if i were you, I will do something like this:
<!-- small devices non-retina (apple use 2x for ipads and 3x for the newest iphones) -->
<link media="only screen and (max-width: 800px)" href="..." rel="stylesheet" type="text/css">
<!-- small devices retina (apple use 2x and 3x) -->
<link
media="only screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 800px),
only screen and (min--moz-device-pixel-ratio: 2) and (max-width: 800px),
only screen and (-o-min-device-pixel-ratio: 2/1) and (max-width: 800px),
only screen and (min-device-pixel-ratio: 2) and (max-width: 800px),
only screen and (min-resolution: 192dpi) and (max-width: 800px),
only screen and (min-resolution: 2dppx) and (max-width: 800px)"
href="..." rel="stylesheet" type="text/css">
<!-- bigger devices low-res -->
<link media="only screen and (min-width: 801px) and (max-height: 899px)" href="..." rel="stylesheet" type="text/css">
<!-- bigger devices higher res -->
<link media="only screen and (min-width: 801px) and (min-height: 900px)" href="..." rel="stylesheet" type="text/css">
If you see in this article of CSS Tricks: Media Queries for Standard Devices you can go very specific trying to point each devices. Or get use of some of this examples (maybe in combination with orientation: portrait)
Lastly I'll like to say that, personally, I only use the -webkit-min-device-pixel-ratio: 2 or -webkit-min-device-pixel-ratio: 3 to point to the high-res raster/bitmap images (jpg and png) I'll use.
I hope this help.
You can find more info about 2x and 3x devices and how this affects images on this article from Apple.
Other resources:
MDN Media Queries.
Already mentioned by another answer (CSS Tricks): Retina Display Media Query.
Already mentioned by myself, also CSS Tricks: Media Queries for Standard Devices
A comparative of devices and screens: A quick reference for iOS devices
More official sources:
W3C Recommendation 19 June 2012 - Media Queries - Resolution
Apple's Safari Web Content Guide - Optimizing Web Content
Android's Supporting Multiple Screens
iPad pro has a retina display, with a pixel aspect ratio of probably 2, which makes virtually 2 x 800 = 1600 pixels. That's why the selected media query is the wrong one. You'll have to deal with pixel aspect ratio too. See this : https://css-tricks.com/snippets/css/retina-display-media-query/
This Query working on all device I hope your issue is resolve.
#media only screen and (max-width:767px){
.big-dot{
width:280px; height:280px; margin:0 auto; background:red;
}
}/*===========Mobile Device=============*/
#media only screen and (min-width:768px) and (max-width:1280px){
.big-dot{
width:280px; height:280px; margin:0 auto; background:green;
}
}/*===========Tab and IPad Pro Device=============*/
#media only screen and (min-width:1280px) {
.big-dot{
width:280px; height:280px; margin:0 auto; background:cyan;
}
}/*===========Large Desktop Device=============*/
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div class="big-dot">
Time Big Dot /.....
</div>
</body>
</html>
have you included <meta name="viewport" content="width=device-width, initial-scale=1.0"> in your <head>? I find including this makes retina devices behave as expected without any extra fiddling with 2x and 3x devices mentioned by f-spin
edit: just beware, you may find this affects layout that currently works well, but overall should make media queries more predictable once you've got over that (probably quite small) hump
As per my knowledge resolution of iPad Pro is (1024x1366)px and iPad Pro9.7 is (768x1024)px. So if you want to load specific stylesheet for specific resolution, then you might be load the stylesheet of
<link media="only screen and (min-width: 768px) and (max-width: 1199px)" href="..." rel="stylesheet" type="text/css">
I think this will help you.
This Query working on all device I hope your issue is resolve.
/*---------------------------------------------------------------------
Large Desktops
-----------------------------------------------------------------------*/
#media only screen and (min-width: 992px) and (max-width: 1200px) {
}
/*---------------------------------------------------------------------
Desktops
----------------------------------------------------------------------*/
#media only screen and (min-width: 768px) and (max-width: 991px) {
}
/*---------------------------------------------------------------------
Tablets Devices
-----------------------------------------------------------------------*/
#media only screen and (min-width: 480px) and (max-width: 767px) {
}
/*----------------------------------------------------------------------
Mobile Devices
------------------------------------------------------------------------*/
#media only screen and (min-width: 360px) and (max-width: 479px) {
}
/*----------------------------------------------------------------------
Small Screen Mobile Devices
-----------------------------------------------------------------------*/
#media only screen and (min-width: 320px) and (max-width: 359px) {
}
Related
I have been struggling with the iPad portrait view of a post grid on my site. The grid looks fine in all other view except for this one, where the grid appears on the far right-hand side of the container.
The theme's (Alexandra) CSS is as follows:
#media only screen and (max-width: 941px) and (min-width: 768px).container {width: 726px;}
I've tried to modify this by using:
#media only screen and (min-device-width: 768px) and (max-device-width: 941px) and (orientation:portrait) .container {width:510px;}
And:
#media only screen and (min-device-width: 768px) and (max-device-width: 941px) and (orientation:portrait) { .container {width:510px !important;}}
Also:
#media only screen and (min-device-width: 768px) and (max-device-width: 941px) and (orientation:portrait) { .container {margin-right: 200px;}
As well as several other configurarions and nothing happens. Any ideas on what I'm missing or why this isn't working or changing anything? Thank you so much for reading! Any insight is greatly appreciated!
HTML5 introduced a method to let web designers take control over the viewport, through the <meta> tag.
So you should add to index.html this meta:
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
I'm working on developing this responsive Wordpress site: http://www.allisoncassels.com/Test/ and having a problem with my media queries.
I coded the CSS for the following breakpoints:
/* Portrait Tablets */
#media only screen and (min-width: 768px) and (max-width: 959px)
/* Portrait Mobiles */
#media only screen and (max-width: 767px)
/* Landscape Mobiles */
#media only screen and (min-width: 480px) and (max-width: 767px)
On desktop, everything looks great. On my phone and tablet, some things are mobile and some things are still showing like the desktop (stuff I have display: none on is showing, div widths are off, etc.)
The only thing I can figure out is that it's related to my phone/tablet being retina display, but I don't see other sites having to factor that into their calculations...
Really baffled right now, I'll appreciate any help. Thanks
Put this in your head!!! :P
Inside the meta tag.
name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
Cheers,
Mark
You should add this meta
<meta name="viewport" content="width=device-width, initial-scale=1">
Try this media query for iPhone 6/6 Plus and Apple Watch CSS media queries
#media only screen and (min-device-width: 375px)
and (max-device-width: 667px)
and (orientation: landscape)
and (-webkit-min-device-pixel-ratio: 2)
{ }
iPhone 6 portrait
#media only screen
and (min-device-width: 375px)
and (max-device-width: 667px)
and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 2)
{ }
iPhone 6 Plus landscape
#media only screen
and (min-device-width: 414px)
and (max-device-width: 736px)
and (orientation: landscape)
and (-webkit-min-device-pixel-ratio: 3)
{ }
iPhone 6 Plus portrait
#media only screen
and (min-device-width: 414px)
and (max-device-width: 736px)
and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 3)
{ }
iPhone 6 and 6 Plus
#media only screen
and (max-device-width: 640px),
only screen and (max-device-width: 667px),
only screen and (max-width: 480px)
{ }
Apple Watch
#media
(max-device-width: 42mm)
and (min-device-width: 38mm)
{ }
For Image responsive
img {
max-width: 100%;
}
This wordpress theme Avando is already responsive:
http://themefurnace.com/themes/?theme=Avando
you don't need to create some additional css
Update
My web host's server was crashing while I was working last night and I think that was affecting the files being properly propagated... All the responsive code works perfectly today.
Try adding a color css border around elements that are not displaying correctly, border:thin red solid; or change the background-color to figure out if you css selector is being used. Also, it will be usefull if you put in links to the page and point out the elements you are having issues with and the device/device browser you are testing on.
maybe this is simple but I havent found the answer yet
How do I detect either iphone, ipad, ipad, android phone in any mode via CSS?
I read this
Detect iPhone/iPad purely by css
that describes how to detect all the specific devices
But what I am looking for is to distinguish between desktop/laptop AND all ipad/ipod/iphone/android devices in general
Here are my notes on the matter: For any device - do your research on it's screen sizes and ratios and then do a #media query in your stylesheet for each device.
iPhone4
<link rel="stylesheet" media="only screen and (-webkit-min-device-pixel-ratio: 2)" type="text/css" href="iphone4.css" />
(portrait or landscape) on the iPad
<link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css">
<link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css">
Mobile Phones Portrait
#media screen and (max-device-width: 480px) and (orientation: portrait){
/* some CSS here */
}
Mobile Phones Landscape
#media screen and (max-device-width: 640px) and (orientation: landscape){
/* some CSS here */
}
Mobile Phones Portrait or Landscape
#media screen and (max-device-width: 640px){
/* some CSS here */
}
iPhone 4+ Portrait or Landscape
#media screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2){
/* some CSS here */
}
iPhone 5 Only
#media only screen and (min-device-width: 640px) and (max-device-width: 1136px) and (- webkit-min-device-pixel-ratio: 2) {
/* styles here */
}
iPhone < 5: aspect ratio
#media screen and (device-aspect-ratio: 2/3) {}
Tablets Portrait or Landscape
#media screen and (min-device-width: 768px) and (max-device-width: 1024px){
/* some CSS here */
}
Desktops
#media screen and (min-width: 1024px){
/* some CSS here */
}
Styles only between two sizes.
#media screen and (min-width: 319px) and (max-width: 1281px){}
BTDUBS - Did you know that WordPress has an is_iphone() global built in?
global $is_iphone;
if ( $is_iphone ) {
// do something if $is_iphone is true
}
you could use #media queries to solve your problem, the below maybe something you could try. You can also you device orientation as a setting to target your devices or set your max width like below and then write your css. Hope this helps.
#media screen and (max-device-width: 480px) {
.class {
background: #000;
}
}
I need to float a div to the left when on the portrait mode via iPad. No matter what code that's inserted, nothing changes. Here's what I'm doing:
#media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
.logos{
float: left;
}
}
The site I'm working on: http://rachelsilberman.com/rob-anolik/
The "logos" div pushes down when someone is on the iPad, and I need it to float left so it will align with the contact div.
I've been using ipadpeek.com to view the outcome since I don't have one myself. Hopefully that doesn't make a difference.
Thanks!
You should be adding the attribute to your ipad css like below:
#media only screen and (min-device-width: 768px)
and (max-device-width: 1024px) and (orientation:portrait) {
.logos{
float: left;
}
}
GENERAL RULE FOR CSS FOR IPAD IS LIKE BELOW:
<link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css">
<link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css">
I figured it out tonight. This may help others. I had to comment out the following line in my library.php file:
<!--<link rel="stylesheet" href="<?php echo get_template_directory_uri()?>/css/tablet.css" type="text/css" media="screen and (min-width:640px) and (max-width:1023px)" />!-->
After this, everything referred to the main style.css sheet which I wanted. I included two statements:
#media only screen and (min-width:641px) and (max-width:1023px) and (orientation:portrait) {
and
#media (max-device-width: 600px) and (orientation: portrait) {
Due to the issues I was observing on a Blackberry Playbook versus an iPad, I had to introduce the second #media line. I simply tweaked the values within those sections of my style.css code and voila! Everything works finally.
Here's a great site on the different sizes for screens: http://nmsdvid.com/snippets/
I'm pretty new in this area of developing, and I'm trying to figure out the making of iOS app using Phonegap. I've created four different CSS files for different resolutions.
<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="css/ipad.css" type="text/css" />
<link rel="stylesheet" media="only screen and (max-device-width: 2048px)" href="css/ipad-retina.css" type="text/css" />
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="css/iphone.css" type="text/css" />
<link rel="stylesheet" media="only screen and (max-device-width: 960px)" href="css/iphone-retina.css" type="text/css" />
I found out that the Simulator always loads the same CSS file, even if I change devices. Is there any way to make it load css files properly?
Thanks people and by the way is my CSS calling correct?
Here is a way to achieve what you are after. Include the specific CSS required in each section.
/* 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) {
}