css – 禁用Internet Explorer 11 Auto Scaling缩放到视口宽度 – IE11

有没有办法阻止Internet Explorer 11中的“自动缩放到视口宽度”(a.k.a.自动缩放)功能?

我想强制浏览器遵循我的最大宽度规则,并阻止它将页面内容自动缩放到视口的整个宽度.

我在“桌面”和“地铁”模式下在Surface Pro 2上看到了IE11中的问题.该问题在here中讨论过,并且可能与外部显示有关,虽然无论是否连接了外接显示器我都会遇到这种情况,并且Surface显示器和外接显示器都会进行缩放.

Microsoft文档中的此page建议您可以使用此CSS规则选择退出“自动缩放”:

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

但那不适合我;它只是默认隐藏垂直滚动条.页面仍然会缩放到视口的整个宽度,忽略CSS中设置的任何最大宽度值.

这是它在docs中所说的内容:

By default, the Internet Explorer in the new
Windows UI automatically scales content when the window is narrower
than 1024 pixels. This primarily includes the snapped state and
portrait mode.

However, in cases where this automatic scaling is not
needed or desired, the device-width keyword can be used. This keyword
signifies that the page is optimized to work well regardless of the
width of the device.

我所经历的实际上与文档所说的完全相反.当视口宽度超过1024像素时,内容会自动缩放.

这是我为meta视口标记设置的内容:

<meta name="viewport" content="width=device-width,initial-scale=1">

最佳答案 Surface可能无法触发媒体屏幕.您应该从te媒体查询中删除它或仅调整查询.

@media only screen {
    @-ms-viewport { width: device-width; }
}

进一步:

> @-ms-viewport rule
> Media Queries

点赞