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

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.

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/

iphone 5 landscape media query failing

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.

How to Troubleshoot media queries on different browsers?

I have a website (http://www.sealinesd.com) that works just fine most of the time...but sometimes the browser (Firefox and Chrome) will determine the wrong screen size and show the site wrong. The same computer will show it differently on two different browsers: one browser will determine that the screen is 960-1240 and the other will correctly see that it's over 1240. I can't figure this out. Anybody have some good tools for troubleshooting this issue, or better yet, know what the problem might be?
OK, I figured it out. Some of my browsers had a tiny bit of zoom magnification. That was screwing up how the browser pixel size was read because browser zoom basically stretches the pixels: 200% zoom on a 1024x768 screen will be read as a 612x384 screen. I changed the media queries in CSS to use ems instead of pixels and that fixed the issue. If you have this issue, just go into your style sheet and change the pixels to ems by dividing pixels by 16 and adding "em" to the end instead of "px".
Example: "#media only screen and (min-width:960px) and (max-width:1240px) {"
WOULD BECOME "#media only screen and (min-width: 60em) and (max-width: 77em) {"
Now users can zoom without changing the query because em (the length of the letter "m") is a measurement that is based on the text size, which is changing proportionally to the page.

iPad 2: problems with correct menu display

I have problems with correct display of some parts of my header on Ipad 2 (social icons in the right top corner)
Here's my site: link
And here you can see how it looks on Ipad:
link
I tested my site on different mobile devices emulators and it looks very well. In reality icons are moved to the bottom of the header and whole header is stretched.
I can't figure it what's wrong. I'd be grateful for some help.
Mobile Safari (like Chrome for Android, Mobile Firefox and IE Mobile) increases the font size of wide blocks (at all times), such that if you double-tap to zoom in on that block (which fits the block to the screen width), the text will be legible. If you set -webkit-text-size-adjust: 100% (or none), it won't be able to do this, and so when a user double-taps to zoom in on wide blocks the text will be illegibly small; users will be able to read it if they pinch-zoom in, but then the text will be wider than the screen and they'll have to pan horizontally to read each line of text!
Ideally you would fix this by using Responsive Web Design techniques to make your design adapt to mobile screen sizes (in which case you would no longer have any very wide blocks, so mobile browsers would no longer adjust your font sizes).
Finally if you really need to prevent Mobile Safari from adjusting your font sizes you can set -webkit-text-size-adjust: 100%, but do this only as a last resort since it is likely to cause mobile users to have difficulty reading your text, as it'll either be too small or they'll have to pan from side to side after every line they read. Note that you must use 100% not none because none has nasty side-effects in desktop browsers. There are also equivalent -moz-text-size-adjust and -ms-text-size-adjust properties for Mobile Firefox and IE Mobile.
Edit: for example in your case the simplest is probably the 2nd alternative, so you could try adding the following CSS:
/* Mobile browsers only */
#media only screen and (max-device-width: 480px) {
.newsletter_input {
width: 320px;
}
.newsletter_input #form{
font-size:42pt
}
}
Though it's not ideal to hardcode 320px like this; you could improve on that by using a variety of CSS media queries, or getting the device-width from JavaScript.

Resources