简体   繁体   English

屏幕阅读器未正确读取价格(“$47.49”)

[英]Screen reader is not reading the price ("$47.49") properly

I am trying to make the screen reader (NVDA) to read my currency value (US dollar) $47.49 as "47 Dollars 49 Cents", but the screen reader is reading my currency value as "Dollar 4749".我试图让屏幕阅读器 (NVDA) 将我的货币价值(美元)47.49 美元读取为“47 美元 49 美分”,但屏幕阅读器将我的货币价值读取为“4749 美元”。

<div class="perVendorCarDetails">
  <span class="carCurrencySymbol">$</span> 
  <span class="carPriceDollar">38</span>           
  <span class="carPriceDot">.</span> 
  <span class="carPriceCents">57</span>
</div>

Your example is spoken by NVDA/Firefox as "dollar thirty-eight dot fifty seven."您的示例被 NVDA/Firefox 称为“38 美元点 57 美元”。 This is not good.这是不好的。

If you just coded it as <p>$38.57</p> it would be read as "dollar thirty-eight point five seven."如果您只是将其编码为<p>$38.57</p> ,它将被解读为“美元三十八点五七分”。 As unpleasant as that seems/is, it is what NVDA users expect.尽管这看起来令人不快,但这正是 NVDA 用户所期望的。

If I go to Amazon, for example, I get "dollar one point two nine" for $1.29 .例如,如果我去亚马逊,我会以 1.29美元的价格获得“一分二九”。 Target, which went through a pretty widely-publicized accessibility lawsuit, hired an accessibility consulting firm, built an accessibility team, and performed extensive testing with screen readers, announces $39.99 as "dollar thirty-nine point nine nine." Target 经历了一场广为人知的无障碍诉讼,聘请了一家无障碍咨询公司,建立了一个无障碍团队,并使用屏幕阅读器进行了广泛的测试,宣布39.99美元为“三十九点九九”。

So the most important thing you may want to do is not confuse NVDA users when they want to spend money.因此,您可能想要做的最重要的事情是不要在NVDA 用户想要花钱时混淆他们。 Presenting dollar values in a different way than they expect can do that.以不同于他们预期的方式呈现美元价值可以做到这一点。

However , if you are adamant that this must happen, you can use aria-hidden to hide the value you do not like from NVDA, and then you can write the phrase that you want into the page after it, hiding it from all other users via an off-screen CSS technique intended to do just this.但是,如果您坚持必须发生这种情况,您可以使用aria-hidden将您不喜欢的值从 NVDA 中隐藏,然后您可以在它之后的页面中写入您想要的短语,对所有其他用户隐藏它通过旨在做到这一点的屏幕外 CSS 技术

Your new HTML:你的新 HTML:

<p aria-hidden="true">
  $38.57
</p>
<span>38 dollars and 57 cents</span>

Obviously you will need to break the dollar amount into two variables and write each twice.显然,您需要将美元金额分成两个变量并分别写入两次。

The aria-hidden="true" hides the <p> text from screen readers, so a screen reader will only read what is in the <span> . aria-hidden="true" <p>屏幕阅读器隐藏<p>文本,因此屏幕阅读器只会读取<span>

Now the CSS to hide the contents of the <span> from your users:现在使用 CSS 来向用户隐藏<span>的内容:

p[aria-hidden=true] + span {
  position: absolute;
  clip: rect(1px 1px 1px 1px);
  clip: rect(1px, 1px, 1px, 1px);
  padding: 0;
  border: 0;
  height: 1px;
  width: 1px;
  overflow: hidden;
}

You will clearly need to change the selector based on your elements, IDs, classes, etc.您显然需要根据您的元素、ID、类等更改选择器。

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

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