如何防止 html/css 文本大小增加
该网站看起来非常不错,尽管它已设法阻止用户通过浏览器功能增大/减小字体大小。
如果您在浏览器上选中仅缩放文本选项并尝试放大或缩小(通常是 ⌘+ / ⌘- 或 ctrl+ / ctrl-) 你可以看到字体大小没有改变。
如何复制相同的效果?
我认为这可以很好地防止菜单中的项目或纯粹基于布局的元素,而只影响主要文本。
this website looks very nice, although the've managed to prevent the user to increase/decrease the font size through the browser facility.
If you check the Zoom Text Only option on your browser and try to zoom in or zoom out (usually ⌘+ / ⌘- or ctrl+ / ctrl-) you can see that the font-size doesn't change.
How can I replicate the same effect?
I am thinking that this would be nice to prevent items from menu or purely layout based elements and leave only the main text be affected.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从他们的 CSS 来看,可能是这行代码:
-webkit-text-size-adjust:none;
如果是这样,它只能在有限数量的浏览器中运行,而不是在所有浏览器中运行。不过,您没有太多理由阻止用户调整文本大小。是的,这可能会导致设计出现问题,但您也可能会认为设计应该足够灵活以处理字体大小的变化。
喜剧选项:用图像替换所有文本。
From looking at their CSS, it might be this line of code:
-webkit-text-size-adjust:none;
If so, it'd only work in a limited number of browsers, not everywhere.There's not much reason you should be preventing users from adjusting text size, though. Yes, it might cause problems with the design, but you could also argue that the design should be flexible enough to deal with font size changes.
Comedy option: replace all your text with images.
使用以下 CSS 代码。
Use the following CSS code.