forked from una/YouMightNotNeedJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve modal dialog accessibility, with warning
Working Codepen (I wasn't sure if there was more to publish): http://codepen.io/marcysutton/pen/mAKrxb
- Loading branch information
Marcy Sutton
committed
Oct 13, 2016
1 parent
280c5e8
commit c029d31
Showing
3 changed files
with
26 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<button>Click Me</button> | ||
<a class="modalTrigger" href="#modalDialog1"> | ||
Click Me | ||
</a> | ||
|
||
<div class="modal"> | ||
<dialog class="modal" id="modalDialog1" tabindex="-1"> | ||
<p>Hello Beautiful!</p> | ||
</div> | ||
</dialog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
// modal is invisible until | ||
// sibling is focused | ||
// Modal is visually hidden until focused. | ||
// This only sort-of works: you can't close | ||
// the dialog with the escape key, and it can't | ||
// contain anything interactive for 2 reasons: | ||
// you wouldn't be able to tab without blurring | ||
// the dialog, and they'd be focusable when | ||
// the dialog is closed (a poor keyboard experience). | ||
.modal { | ||
opacity: 0; | ||
visibility: hidden; | ||
} | ||
|
||
// modal fades in when button | ||
// is in focus (i.e. clicked on) | ||
button:focus + .modal { | ||
.modal:focus { | ||
opacity: 1; | ||
visibility: visible; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters