iphone 5 landscape media query failing - css

I've seen other questions, but no answer has helped me yet.
I have set a media query to:
#media only screen and (max-device-width: 767px) {
/* css here */
}
which I want to make the page on phones render the same in both landscape and portrait.
on my 2 available iphone 5's - a 5 and a 5c, portrait works great, landscape totally ignores it.
i've tried the specific landscape orientation tags, and that also fails.
i've also tried setting the max width to 1500px just in case of some retina thing - and that also fails in landscape.
i've run the css through lint - and that didn't find anything all that bad, even. so i think the css is ok (if not lint-perfect).
the site is locked for now till i hear back from my client - so posting a link won't help. But has anyone else seen this issue, and is there any fix out there? When i get back home tomorrow i can try an old Android phone and see what that does. But for now it's driving me crazy!

Do you have to use max-device-width? because if you change it to use max-width you will keep all the styles up to that size.
The difference between them two is max-device-width if you view the site on a browser and shrink it down it doesn't become responsive but if you use max-width it gives the site a responsive feel when shrinking the browser.
#media all and (max-width: 767px) {
css in here
}
I prefer using max-width.
The only case I can think of we should use max-device-width rather than max-width is when we need to keep something consistent even when browser window has been re-sized.

Related

How to set css value per operating system in Wordpress?

I know I know it is probably only a workaround but I am only a Wordpress amateur and currently need a quick solution, even if a dirty one...
My Wordpress site has a side bar. Unfortunately I have a problem where on android (and probably IOS as well - didn't check) the side bar takes almost half the width of the mobile screen, and in windows, on a pc\laptop screen it looks ok.
So, I narrowed in the custom CSS the sidebar width and now I've got the opposite problem. Looks find on mobile and bad on the PC monitor.
I am using Helium theme.
This is the css value I use to set the sidebar width:
width: calc(100% - 100px);
I checked "Browser and Operating System Finder" plugin but failed to understand how to utilize if for my needs.
I guess the pros have better solution, but even a quick and dirty will be welcomed for now.
An example of the sidebar(filled with button widgets) overlapping the background items on PC screen:
Thank you.
You shouldn't be looking at determining what to display based on device, but rather on characteristics, and for this I would recommend css media queries https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
This allows you to change css based on size and other factors e.g
#media (min-width: 300px) and (max-width:480px) {
/* styles here */
}
You can even add things such as orientation
#media (orientation: landscape) { ... }
The reason this is better than just looking for a specific device e.g iphone is that if Apple released a new iPhone that had an even bigger screen, your standard stylesheet might work, or it might not. Media queries will allow you greater flexibility going forward.

Media queries in different browsers

I am using media queries in order to achieve responsive design. But I have found out that each browser behaves differently with it for example.
At resolution 480x856 chrome uses rules from #media screen and (max-width: 480px) but Firefox uses rules from #media screen and (max-width: 680px) is there a way to achieve same result in all browsers?
I find this post, maybe can help you.
"...It’s actually not a CSS or CSS interpretation problem at all–it’s the way Firefox does (or doesn’t) resize the viewport. Unlike Google Chrome, and most other browsers, Firefox allows it’s toolbars to affect viewport size. The only way to make the viewport resize below the width of your toolbars in Firefox is to disable them. You’ll need to go to View > Toolbars and uncheck each. Then try resizing and watch your media queries take effect."
https://css-tricks.com/forums/topic/firefox-ignoring-max-width320px-media-query/

Chrome Emulator Issues | Media Queries

I'm testing my responsive website and sadly, the Chrome emulator is not showing the responsive views when I select a device e.g "iPhone 6". The nasty scroll bars appear and looks horrible however, when I resize my browser the breakpoints are working perfectly?
This is how I am defining my breakpoints - the variable $screen-md is set within a variable. I'm using SASS.
#media screen and (min-width: $screen-md) { }
Here is a screenshot of what's happening in the Chrome Emulator.
1) Check if $screen-md is storing 375px since Iphone6 is 375px wide
2) Change your min-width to max-width.
Explanation with example:
#media only screen and (min-width: 375px) {...}
above code means "If [device width] is greater than or equal to [375px], then do {...}"
#media only screen and (max-width: 375px) {...}
above code means "If [device width] is less than or equal to [375px], then do {...}"
3) My personal experience with Chrome is that it sometimes doesn't load the media queries even if you are on the right viewport size. A few times, I had to increase the max-width value by 1 or 2 pixels to make it work. Try that too! Also, don't forget to clear your cache and refresh the page.

Stop Firefox DPI Scaling (when Windows setting is at 125%)

I'm currently making a webpage and testing it in chrome works fine, but in Firefox - it is zoomed in.
This is because my DPI in Windows is set to 125%, and Firefox detects this, and adjusts every webpage accordingly.
However, my webpage is not meant to be viewed at such a zoom level, the images aren't made to be displayed that big, and hence it looked blurred/pixelated. The general layout of the page is messed up too, because everything is so big.
Now, this doesn't affect most people - as their DPI would be at 100% in Windows. However, I want it to be the same on all browsers.
I've searched and have found solutions as for the user to disable this "feature" - but I want to be able to disable it from my website - so it doesn't look wrong to the user in the first place.
e.g. one post says:
1) Type about:config in address bar
2) search for layout.css.devPixelsPerPx
3) change value of layout.css.devPixelsPerPx from -1.0 to 1.0
But that isn't what I'm looking for.
Is there any way to disable this from CSS/HTML/anything?
Thanks.
You could easily let your website address users with settings at higher zoom levels by including a media query like:
#media only screen and( -webkit-min-device-pixel-ratio: 1.25 ),
only screen and( -o-min-device-pixel-ratio: 5/4 ),
only screen and( min-resolution: 120dpi ),
only screen and( min-resolution: 1.25dppx ) {
body {
font-size: 1rem;
}
}
See this article for an extended explanation and why the cleaned up solution of the media query is sufficient for a broad browser support: IE9+, Fx3.5+, Opera9.5+, Webkit Browsers Chrome and Safari, both Desktop and Mobile.
Your could try something like this below. There are some caveats using this, but for some situations
it is worth using it.
#media screen and (min-resolution: 120dpi) {
/*body {transform: scale(0.8);width: 125%;height: 125%;margin-left: -12.5%;}*/
body {transform: scale(0.8);transform-origin:top left;width: 125%;height: 125%;}
}
Commented /*body....*/ example scale may be easier to understand yet worse, f.e. because
scaling should be done based on transform-origin css rule top left edge. Then things can be rendered better especially in Chrome.
if you use width: 125%, your RWD css should react differently to changing browser sizes on account of this from what you expected when screen ratio was 100%.
And you might reasonably accept this - this is RWD and the difference is 25%. But some people might want to adapt their css like this:
#media screen and (min-width: 1000px)
you also need to adjust:
#media screen and (min-width: 800px)
probably not 1250px but 800px like I did.
Edge, Chrome, FF do pretty good. IE 11 rendered the worst yet not hopelessly.
There are some problems in FF (not edge, chrome) when expanding select fields - solution css select.
Some borders can can be visible some dissapear on FF (maybe not edge, chrome)
There can be some issues not mentioned here like when you use carousel like owlcarousel on your page.
Yet I think it is greater probability to save more time with this example tested still too little.
You have to use exact scaling like 0.8 for 125% screen for your images to be rendered as sharp as possible.
I noticed that when switching to different dpi resolutions using ctrl +/i in a desktop browser and for sure using multitouch gestures in mobile browsers, a browser changes dpi too, so any solution using #media min/max-resolution may not work as expected. What is needed in css is to read system resolution not a browser. However as i see this resolution change doesn't take place like then when someone changes browser size manually or by rotating a mobile device.
Thank you Tatsuyuki Ishi for correcting some errors of my answer.
This frustrated me too, but luckily there is a solution.
Navigate to about:config. (Click accept on any warnings telling you to be careful with advanced features)
Search for layout.css.devPixelsPerPx and change its value to 1.0 and your issue should be fixed.
It was something implemented in Firefox 22.
I did this way, zoom works better than transform, it doesn't make fixed elements absolute:
#media screen and (min-resolution: 120dpi) {
body {zoom: 0.8;}
}
Set it to 1.25: that keeps the user interface larger, but resets the website to 100% pixel mapping.

Same website on different devices?

Im working on a website that im trying to make responsive.
So far , it works on desktop and mobiles phones (iphone , galaxy s4..ect)
Im having a hard time trying to make the website, when its on tablets (ipad , nexus 7 ..) look like its on a mobile phone.
My website is here - http://mk18.web44.net/index2.php
you can use http://quirktools.com/screenfly/ to see what I mean. Change the setting to a mobile phone like iphone. Thats what I want it to look like on an ipad.
You can look through the css - http://mk18.web44.net/css/styles.css
Thanks
For what I've seen, it seems to me that you are trying a bit too hard.
In order to make it like for iphones, you have to make the media query of #media(max-width: 768px) with the same instructions as the #media(max-width: 360px).
If that's what you want, my advice is to remove the #media(max-width: 360px) completely and just leave the #media(max-width: 768px) - the css instructions within will only be applied for devices smaller than 768px in width (this includes iphones, and other phones).
Also, you should do some clean up. Css code will be parsed from top to bottom, so css instructions without any media query (the #media bit) will always be applied in all devices, until there is an override. One can create as many #media queries as needed, but that doesn't mean you should.
With the right css foundation, you can accomodate most devices without media queries, using them only to reorganize content and user interface just enough so that it remains usable.
Hope it helps.

Resources