[英]What would be the best way to implement a text size accessibility feature?
I need to implement a feature into a web app i'm building that will increase text size / window zoom to assist in reading text. 我需要在正在构建的Web应用程序中实现一项功能,该功能将增加文本大小/窗口缩放以帮助阅读文本。
The best method in my head would be to simulate a browser zoom so that my media queries are also taken into account and the layout doesn't break, but i'm not sure of the best way / if this is possible. 在我看来,最好的方法是模拟浏览器缩放,以便也考虑我的媒体查询并且布局不会中断,但是我不确定最好的方法/如果可能的话。
CSS zoom isn't really an option due to the framework using media queries. 由于该框架使用媒体查询,因此CSS缩放并不是真正的选择。
Any help / other ideas would be greatly appreciated! 任何帮助/其他想法将不胜感激!
Well, as @slugolicious said, you probably should be steering users to use their browser's inbuilt browser zooming features. 好吧,正如@slugolicious所说,您可能应该引导用户使用其浏览器的内置浏览器缩放功能。
However, it's entirely possible this is a client/business requirement, so I'll suggest something. 但是,这完全有可能是客户/业务需求,因此我将提出一些建议。
Your best bet is to place a CSS class on your content holding element that adjusts the user's font size. 最好的选择是将CSS类放在您的内容保存元素上,以调整用户的字体大小。
Here's some css classes: 这是一些CSS类:
#content.font-lg {
font-size: 125%;
}
#content.font-xl {
font-size: 150%;
}
And to trigger them, some JavaScript: 并触发它们,一些JavaScript:
function onLargeFontButtonClick() {
var element = document.getElementById('content');
element.className = 'font-lg';
}
function onExtraLargeFontButtonClick() {
var element = document.getElementById('content');
element.className = 'font-xl';
}
function onNormalFontButtonClick() {
var element = document.getElementById('content');
element.className = '';
}
If you already have classes on your content area, you might want to use += instead for the classname, possibly removing instances of the other font class. 如果内容区域中已经有类,则可能要使用+ =代替类名,可能会删除其他字体类的实例。 Adjust to your needs.
适应您的需求。
I hope this helps! 我希望这有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.