简体   繁体   English

如何通过制表结构使悬停状态显示文本可访问?

[英]How to make hover-state revealed text accessible through tab structure?

I've been working on a web component that will hide/reveal content by hovering over a <div> . 我一直在研究一个通过将鼠标悬停在<div>隐藏/显示内容的Web组件。 I've got the functionality working the way I want, but I just realized isn't accessible via tabbing. 我的功能按照我想要的方式工作,但我刚才意识到无法通过tabbing访问。

I was able to include tabindex="0" role="button" aria-pressed="false" to each of the <div> boxes, which allows you to toggle between each box, but I have no way of revealing the hidden content. 我能够将tabindex="0" role="button" aria-pressed="false"在每个<div>框中,这样你就可以在每个框之间切换,但我无法揭示隐藏的内容。

You can find my code here, which demonstrates the issue: https://codepen.io/ckatz/pen/XQaKdB 你可以在这里找到我的代码,它可以解决这个问题: https//codepen.io/ckatz/pen/XQaKdB

Is there a markup I'm missing to allow for someone to hit Enter to show the text? 是否有一个标记我错过了允许有人按Enter显示文本?

I added this to your CSS and it worked when i press TAB and move from div to div: 我把它添加到你的CSS中,当我按下TAB并从div移动到div时,它有效:

.color:focus {
    /* Change the flex-basis so that we know what
    size to transition to on hover. Arbitrary,
    based on our design/content.
  */
    flex-basis: 20em;
}

.color:focus .details {
    opacity: 1;
}

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

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