简体   繁体   English

浏览器缩放未对齐的解决方法

[英]Browser Zooming Misaligned Workaround

I have a website that when the user zooms, lines no longer line up exactly in some situations. 我有一个网站,当用户放大时,线条在某些情况下不再完全排列。 Unfortunately, I don't have an example to show, but I know this has to do with my lack of understanding of how zooming works. 不幸的是,我没有一个展示的例子,但我知道这与我对缩放如何工作缺乏了解有关。 I assume this has to do with things like when you zoom, a pixel may end up becoming two pixels because a single old pixel gets drawn on half of two new pixels, depending on how the zoom affects the pixel orientation. 我认为这与缩放时的事情有关,像素可能最终变成两个像素,因为一个旧像素被绘制在两个新像素的一半上,这取决于缩放如何影响像素方向。

Are there any workarounds for dealing with zooming on websites that are very exactly specified, so even a pixel off is noticeable? 是否有任何解决方法来处理非常精确指定的网站上的缩放,所以即使像素关闭也很明显?

There are two types of zoom. 有两种类型的缩放。 One increases fonts only and the other magnifies evenly. 一种仅增加字体,另一种均匀地放大。 If your issue is the second it's highly doubtful there is anything you can do about it. 如果您的问题是第二个,那么您可以做些什么就非常值得怀疑。 If it's the first type then look at how your fonts expand and look for cases where you might want to change from relative units like ems to px (in general fonts specified in px don't zoom). 如果是第一种类型,请查看字体的扩展方式,并查找可能要从诸如ems的相对单位更改为px的情况(通常px中指定的字体不会缩放)。

There are many browser features, that can have designs be "off by a pixel" other than zooming: 有许多浏览器功能,除了缩放之外,设计可以“按像素关闭”:

Different available fonts, different font rendering engines, different rounding methods, different default styles, browser bugs, so this is not really a problem of zooming alone. 不同的可用字体,不同的字体渲染引擎,不同的舍入方法,不同的默认样式,浏览器错误,所以这不是单独缩放的问题。

It's difficult to give specific suggestions, but IMHO the best is to "work with the medium". 提出具体的建议很困难,但恕我直言,最好的是“与媒体合作”。

This starts off with having the original design not based on pixels or as if it were a "fixed" medium such as paper - in other words it begins with the explaining to the customer/boss/designer about the possibilities, but also limits of web design. 这开始于原始设计不是基于像素,或者好像它是一种“固定”介质,如纸张 - 换句话说,它首先向客户/老板/设计师解释可能性,但也限制了网络设计。

For the actual implementation you need embrace "the natural flow" of HTML/CSS. 对于实际的实现,您需要拥抱HTML / CSS的“自然流程”。 Avoid explicit size specifications where ever you can. 尽可能避免使用明确的尺寸规格。 Most importantly avoid fixed heights and absolute positioning. 最重要的是避免固定高度和绝对定位。 It's better to use a table (preferably using display: table-* unless you have to support IE6) than using absolute positioning. 除了使用绝对定位之外,最好使用表格(最好使用display: table-*除非你必须支持IE6)。

Best would be if you posted a URL to your site, or at least an example page, because I'm sure your problem has nothing to do with zooming and everything with inflexible design. 如果你发布了一个URL到你的网站,或者至少是一个示例页面,那将是最好的,因为我确定你的问题与缩放无关,而且设计不灵活。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM