Last active
June 24, 2020 23:24
-
-
Save bwbroersma/d4e2332ee3d95bb7bbe6cb70319a3782 to your computer and use it in GitHub Desktop.
details fallback with 3 extra (hidden) HTML nodes + copy of all summary inner nodes per detail and 19 lines of CSS (for IE11 and Edge 12-18)
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8> | |
<title>test</title> | |
</head> | |
<body> | |
<details class="details"> | |
<summary class="summary">click me to open1</summary> | |
<input type="checkbox" id="toggle1" aria-hidden="true"> | |
<label for="toggle1" aria-hidden="true">click me to open2</label> | |
<div class="more"> | |
more information</div> | |
</details> | |
<br> | |
<detailsNotSupported class="details"> | |
<summaryNotSupported class="summary">click me to open1</summaryNotSupported> | |
<input type="checkbox" id="toggle2" aria-hidden="true"> | |
<label for="toggle2" aria-hidden="true">click me to open2</label> | |
<div class="more"> | |
more information</div> | |
</detailsNotSupported> | |
<style> | |
.details { | |
position: relative; | |
display: block; | |
} | |
.details label { | |
position: absolute; | |
left: 0; | |
width: 100%; | |
} | |
.details input, .more { | |
display: none; | |
} | |
input:checked ~ .more, | |
.details[open] .more { | |
display: block; | |
} | |
.details[open] label { | |
display: none; | |
} | |
.details label { | |
background-color: green; | |
} | |
.details .summary { | |
background-color: purple; | |
} | |
.details { | |
background-color: red; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also see this codepen.
Note: Codepen does not support IE11, and exporting a file as HTML and viewing it locally will lead to different results because of compatibility mode!