简体   繁体   English

如何避免用户能够将浏览器缩放级别设置为低于某个阈值?

[英]How to avoid user to be able to set browser zoom level below a certain threshold?

So basically I want the users of my website to be unable to reduce the zoom level below a certain point, at all times.所以基本上我希望我网站的用户始终无法将缩放级别降低到某个点以下。 The reason to do that is to avoid them to see some pitfalls of my frontend design.这样做的原因是为了避免他们看到我的前端设计的一些陷阱。 Basically I wanted a skewed container abd, in order to do so, I used CSS property transform: "skewY()" to make four divs placed at a certain angle around a rectangular and horizontal "main" div container.基本上我想要一个倾斜的容器 abd,为了做到这一点,我使用了 CSS 属性转换:“skewY()”来使四个 div 以特定角度放置在一个矩形和水平的“主”div 容器周围。 The main one contains the horizontal letters and the corresponding background colour and the other ones just give the skewed component.主要的包含水平字母和相应的背景颜色,其他的只是给出倾斜的组件。 This way the squared central div would appear as if it was at a certain angle, like this:这样,平方的中央 div 看起来就好像它处于某个角度一样,如下所示: 我的设计结果 . .

However, when the zoom level is set below 67%, imperfections arise and users can see the "horizontal div" and two divs that circle it.但是,当缩放级别设置为低于 67% 时,会出现不完美,用户可以看到“水平 div”和环绕它的两个 div。 It just looks ugly at the sizes.它只是在尺寸上看起来很难看。 Even though I tried my best by setting CSS properties such like position relative, z-index, padding, etc.. I couldn't manage to make it perfect, and obviously, I would try to hide the imperfections (since hiding them will not be affecting the overall performance of the website):即使我通过设置 CSS 属性(例如 position 相对、z-index、填充等)尽了最大努力。我无法使其完美,显然,我会尝试隐藏缺陷(因为隐藏它们不会会影响网站的整体性能):

低于 67% 的浏览器缩放级别

How could I just AVOID zoom level to be set below a certain percentage to avoid the imperfections to be seen by anyone in any device?我怎样才能避免将缩放级别设置为低于某个百分比,以避免任何人在任何设备中看到缺陷? Is there a more elegant way to make the "skewed" containers than using accessory divs?有没有比使用附件 div 更优雅的方法来制作“倾斜”容器?

I am not certain that even if you could stop the user zooming to certain levels that it would, in all device/viewport aspect ratios, stop some distortion of your layout.我不确定即使您可以阻止用户缩放到某些级别,在所有设备/视口纵横比中,它也会阻止您的布局出现一些失真。

Instead I wondered whether a background-image would do what you want?相反,我想知道背景图像是否可以满足您的要求?

Here is a linear gradient background which obviously you can alter to have a different angle or colors as you want.这是一个线性渐变背景,显然您可以根据需要更改为具有不同的角度或 colors。 If it sits as the background-image of a div which holds your three inline pieces of information you won't have to worry about distortion.如果它作为包含三个内联信息的 div 的背景图像,则您不必担心失真。

  background-image: linear-gradient(3deg, transparent 15%, #ffe083 15%, #ffe083 18%, #ffc106 18%, #ffc106 82%, #ffe083 82%, #ffe083 85%, transparent 85%);

 * { margin: 0; padding: 0; }.stripe { --w: 100vw; width: var(--w); height: calc(var(--w) / 3); background-image: linear-gradient(3deg, transparent 15%, #ffe083 15%, #ffe083 18%, #ffc106 18%, #ffc106 82%, #ffe083 82%, #ffe083 85%, transparent 85%); }
 <div class="stripe"></div>

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

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