跳转到帖子
在手机APP中查看

一个更好的浏览方法。了解更多

OKCCN - XenForo & IPS Plugin Marketplace

主屏幕上的全屏APP,带有推送通知、徽章等。

在iOS和iPadOS上安装此APP
  1. 在Safari中轻敲分享图标
  2. 滚动菜单并轻敲添加到主屏幕
  3. 轻敲右上角的添加按钮。
在安卓上安装此APP
  1. 轻敲浏览器右上角的三个点菜单 (⋮) 。
  2. 轻敲添加到主屏幕安装APP
  3. 轻敲安装进行确认。
  • 选择语言

CSS Accessibility Styling

推荐的帖子

  • 行政经理

CSS Accessibility Styling


CSS Accessibility Styling

A website should be designed to ensure good accessibility for all users, including those with disabilities.

CSS accessibility styling is about using good styling technics to improve the visual clarity, navigation, and overall user experience. 


CSS Accessibility Styling Technics

Here are some tips and technics on how to improve the accessibility of your web site:

1. Provide High Color Contrast

Always use a good color contrast between the text and the background for readability. This is especially important for users with visual impairments or color blindness.

Good Color Contrast

body {
  background-color: #ffffff;
  color: #000000;
}
Try it Yourself »

Bad Color Contrast

body {
  background-color: #eeeeee;
  color: #cccccc;
}
Try it Yourself »

2. Provide Good Font, Font Size and Line Height

Always provide a font that is easily readable. In addition, use a proper font size and line height. Use relative units (like rem) for font-size, to allow the user to scale the text size in the browser settings.

Good Font Example

body {
  font-family: Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}
Try it Yourself »

Bad Font Example

body {
  font-family: Georgia, serif;
  font-size: 12px;
  font-style: italic;
  font-variant: small-caps;
  line-height: 90%;
}
Try it Yourself »

3. Have Visible Focus Indicators

Always use the :focus pseudo-class to ensure that interactive elements (like links, buttons, input fields) have a clear visual focus style.

Using :focus will ensure that keyboard users and screen-readers understand which element is currently active.

Example

a:focus, button:focus, input:focus {
  outline: 2px solid orange;
}
Try it Yourself »


4. Avoid Hiding Focus

Never remove the default focus outlines, without replacing them with another visible focus style.

Bad Example

button:focus {
  outline: none;
}
Try it Yourself »

Good Example

button:focus {
  outline: 2px solid orange;
}
Try it Yourself »

5. Use CSS + Semantic HTML

Use CSS for visual styling, and structure content with semantic HTML elements (instead of non-semantic elements, like <div> for everything).

Example

nav {
  background-color: #333333;
  color: white;
}
aside {
  background-color: #333333;
  color: white;
}

6. Respect User Preferences

The CSS prefers-reduced-motion @media feature lets you check if a user has asked to reduce motion, such as animations or transitions.

Some users have motion sensitivity and prefer websites with less animation. You can use this media query to turn off, or tone down animations and transitions for the users who has activated this setting on their computer:

Example

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
Try it Yourself »

You will learn more about media queries in a later chapter.


Summary

  • Provide high color contrast
  • Provide easily readable fonts
  • Keep focus outlines visible
  • Use semantic HTML elements
  • Respect user preferences

参与讨论

你可立刻发布并稍后注册。 如果你有帐户,立刻登录发布帖子。

游客
回帖…

帐户

导航

搜索

搜索

配置浏览器推送通知

Chrome (安卓)
  1. 轻敲地址栏旁的锁形图标。
  2. 轻敲权限 → 通知。
  3. 调整你的偏好。
Chrome (台式电脑)
  1. 点击地址栏中的挂锁图标。
  2. 选择网站设置。
  3. 找到通知选项并调整你的偏好。