CSS display:none and visibility:hidden

前端 未结 3 416
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-19 03:07

I have a div that I use to display alerts when needed.

If I want to close it after a while can I use display:none or should I use display:none as well as visibility:

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-19 03:35

    If your hidden content needs to be accessible—to those with screen readers, for example—then you should not use display: none or visibility: hidden, as both can potentially hide content from screen readers. Instead, you should use a more accessible approach, such as moving the content off screen with a negative margin. See the following links for more information:

    456 Berea Street: Hiding with CSS: Problems and solutions
    WebAIM Blog: Hiding content for screen readers

提交回复
热议问题