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

后端 未结 5 973
死守一世寂寞
死守一世寂寞 2020-12-08 13:54

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

相关标签:
5条回答
  • 2020-12-08 14:32

    Set it to 1.25: that keeps the user interface larger, but resets the website to 100% pixel mapping.

    0 讨论(0)
  • 2020-12-08 14:34

    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.

    0 讨论(0)
  • 2020-12-08 14:36

    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.

    0 讨论(0)
  • 2020-12-08 14:42

    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;}
    }
    
    0 讨论(0)
  • 2020-12-08 14:44

    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.

    0 讨论(0)
提交回复
热议问题