[ARIA] Create an Accessible Tooltip on a Text Input
Here we use HTML and CSS to create a stylish yet semantic tooltip on a form input. I am using aria-describedby to create a relationship with the input and the tooltip. Then I use CSS to style the tooltip and control when it appears or disappears both on hover and focus.
We use VoiceOver. To test that on a MacOS, use CMD + F5.
A few resources:
- CSS Triangle
- a11y Style Guide - Tooltips - I used this to gut check and with some help with those transitions.
- Using VoiceOver to Evaluate Web Accessibility
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Egghead A11y Tooltips</title>
<link
href="https://fonts.googleapis.com/css?family=Montserrat"
rel="stylesheet"
/>
<style>
body {
font-family: "Montserrat", sans-serif;
background: #eedbff;
color: #6505cc;
} form {
max-width: 40em;
margin: 1rem;
} .a11y-input-tooltip {
position: relative;
} input[type="text"] {
width: 100%;
max-width: 100%;
padding: 0.75rem;
margin: 8px -2px 20px;
box-sizing: border-box;
border-radius: 4px;
border: 2px solid rgba(101, 5, 204, 0.7);
font-size: 1rem;
min-height: 49px;
} input[type="text"]:focus,
input[type="text"]:hover {
outline: none;
box-shadow: 2px 2px 10px rgba(60, 0, 130, 0.5);
}
input[type="text"]:hover + [role="tooltip"] {
visibility: visible;
opacity: 1;
} [role="tooltip"] {
transition: opacity 0.2s 0.5s ease-in-out;
visibility: hidden;
opacity: 0;
position: relative;
background: #6505cc;
color: #eedbff;
padding: 0.5rem 0.75rem;
border-radius: 5px;
}
[role="tooltip"]::after {
content: "";
position: absolute;
left: 20px;
top: -5px;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid #6505cc;
}
</style>
</head>
<body>
<form>
<label for="name">Name:</label>
<span class="a11y-input-tooltip">
<input type="text" id="name" aria-describedby="a11y-tooltip" />
<span role="tooltip" id="a11y-tooltip"
>Please write your first and last name.</span
>
</span>
</form>
</body>
</html>

[ARIA] Create an Accessible Tooltip on a Text Input的更多相关文章
- iOS programming Delegation and Text Input
iOS programming Delegation and Text Input 1.1 Text Fields CGRect textFieldRect = CGRectMake(40, ...
- Text input(文本输入框)
Text input(文本输入框)是用来获得用户输入的绝佳方式. 你可以用如下方法创建: <input type="text"> 注意,input元素是自关闭的.
- 谈论multistage text input(中国输入法)下一个UITextView内容长度的限制
我以前写<如何更好地限制UITextField输入长度>.接使用 UIKIT_EXTERN NSString *const UITextFieldTextDidChangeNotifica ...
- React Native & Android & Text Input
React Native & Android & Text Input react native clear input value https://stackoverflow.com ...
- playwright-python 处理Text input、Checkboxs 和 radio buttons(三)
Text input 输入框输入元素,直接用fill方法即可,支持 <input>,<textarea>, [contenteditable] 和<label>这些 ...
- [ARIA] What is Accessible Name Calculation?
What's in a name? In this lesson, I'll explain the concept of naming interactive elements for screen ...
- Failed to create a 'System.Type' from the text ' ' in wpf(无法从文本创建类型)
问题描述:WPF is unable to create a type for data templateWPF使用mvvm模式无法加载DataTemplate模板定义的资源,提示无法从文本创建类型错 ...
- Create Custom Modal Dialog Windows For User Input In Oracle Forms
An example is given below to how to create a modal dialog window in Oracle Forms for asking user inp ...
- 2.Text input and output
文本的输入和输出 输出 要在屏幕上输出文本你需要这样一行代码: print("Hello World") 如果输出多行,要添加符号“\n”: print("Hello W ...
随机推荐
- BFS --- 素数环
<传送门> [题目大意]对话很坑爹,不过很有意思,直接看题干就可以了.给你两个四位数a和b,现在要你从a经过变换得到b,并且变换的中间的每一位都要是素数,并且相邻两个素数之间只能有一个位不 ...
- Shell的展开
Shell的展开 2018-5-30 Writen By Stephen.Yu 一.路径名展开 shell执行echo命令前,在命令行上自动展开任何符合条件的字符,例如这里,* 被展开成当前的路 ...
- HTTP响应状态
状态码分类 状态码详解 状态码 英文提示 说明 100 Continue 继续 101 Switching Protocols 切换协议.服务器根据客户端的请求切换协议.只能切换到更高级的协议,例如, ...
- Udp客户端与服务通讯
使用UDP与服务端通讯时候,同样需要先启用udp服务端监控,当服务端启动成功,在启动客户端 首先UDP服务端类,代码如下: public class UdpServerTest { public vo ...
- postgreSQL 备份+还原多张表
-U表示用户 -h表示主机 -p表示端口号 -t表示表名 -f表示备份后的sql文件的名字 -d表示要恢复数据库名 一.打开cmd 进入postgresql安装路径下的bin文件夹,以我的为例: cd ...
- 在docker容器上如何实现代码的版本管理
之前在一台centos7的虚拟机上部署了docker并运行了三个容器给开发写代码用,写代码肯定会涉及到版本控制管理. 开始建议是开发在容器中写代码,然后通过docker commit的方式将其保存为i ...
- 【开发工具】- 设置Sublime支持韩文展示
菜单栏 --> 首选项 --> 设置 -->User 添加以下代码 { "font_size": 12, "show_encoding":tr ...
- 解决SqlDataSource连接超时的问题
采用两种策略: 1.连接字符串增加Connect Timeout=1000(大约1000秒/60=16分钟) 2.设置SqlDataSourced 的 EnableCaching="True ...
- 数据仓库模型ETL架构(DWI/DWR/DM)
1.DWI DWI:数据湖.数据砥柱,一般存放在HDFS 数据仓库的基础数据来源,各种杂七杂八的数据 关键点:数据清洗.数据整合.异常处理.增量获取 ETL:E-数据抽取.数据清洁.格式转换,T-生成 ...
- php学习笔记——学习路线图记录
PHP学习路线图 最全PHP自学指南 W3Cschool小编 2018-04-24 15:23:51 浏览数 (5381) 分享 收录专辑 对于广大零基础的PHP自学者,往往不知道如何系统的学习PHP ...