How can I prevent the scrollbar overlaying content in IE10?

前端 未结 6 1836
执笔经年
执笔经年 2020-11-28 17:41

In IE10, the scrollbar is not always there... and when it appears it comes on as an overlay... It\'s a cool feature but I would like to turn it off for my specific website a

6条回答
  •  离开以前
    2020-11-28 18:29

    After googling a bit I stumbled across a discussion where a comment left by "Blue Ink" states:

    Inspecting the pages, I managed to reproduce it by using:

    @-ms-viewport { width: device-width; }

    which causes the scrollbars to become transparent. Makes sense, since the content now takes up the whole screen.

    In this scenario, adding:

    overflow-y: auto;

    makes the scrollbars auto-hide

    And in bootstraps responsive-utilities.less file, line 21 you can find the following CSS code

    // IE10 in Windows (Phone) 8
    //
    // Support for responsive views via media queries is kind of borked in IE10, for
    // Surface/desktop in split view and for Windows Phone 8. This particular fix
    // must be accompanied by a snippet of JavaScript to sniff the user agent and
    // apply some conditional CSS to *only* the Surface/desktop Windows 8. Look at
    // our Getting Started page for more information on this bug.
    //
    // For more information, see the following:
    //
    // Issue: https://github.com/twbs/bootstrap/issues/10497
    // Docs: http://getbootstrap.com/getting-started/#support-ie10-width
    // Source: http://timkadlec.com/2013/01/windows-phone-8-and-device-width/
    // Source: http://timkadlec.com/2012/10/ie10-snap-mode-and-responsive-design/
    
    @-ms-viewport {
      width: device-width;
    }
    

    This snippet is what's causing the behavior. I recommend reading the links listed in the commented code above. (They were added after I initially posted this answer.)

提交回复
热议问题