简体   繁体   English

实施文本大小可访问性功能的最佳方法是什么?

[英]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.

相关问题 在JavaScript中实现“保存”功能以形成表格的最佳方法是什么? - What could be the best way to implement 'save' feature to form in javascript? 实现简单文本搜索的最佳方法是什么 - What is the best way to implement simple text search 实施自动建议功能的最佳方法? - Best way to implement auto suggestions feature? 表单验证正则表达式和DOM:什么是在表单验证中实现正则表达式的最佳方法 - Form validation regex and DOM: What would be the best way to implement regex in a form validation 更改数组的最佳方法是什么? - What would be the best way to change the array? (使用jQuery)实现增加和减小页面字体大小的按钮的最佳方法是什么? - What's the best way (using jQuery) to implement buttons that increase and decrease the font-size of the page? 如果清除这些语句,最好的方法是什么? - What would the best way to clean these if statements up? 显示图像序列的最佳方式是什么? - What would be the best way to show an image sequence? 什么是最好的JavaScript文本编码使用? - What would be the best JavaScript text encoding to use? OR和AND条件未按预期返回-实施它的最佳方法是什么? - OR and AND conditions not returning as expected - What is best way to implement it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM