Created
September 18, 2026 19:29
-
-
Save WesSouza/e0788eed30181fd44d6d03ed7430bf1a to your computer and use it in GitHub Desktop.
Safe-area edge test
This file contains hidden or 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> | |
| <meta charset="utf-8" /> | |
| <meta | |
| name="viewport" | |
| content="width=device-width, initial-scale=1, viewport-fit=auto" | |
| /> | |
| <title>Safe-area edge test</title> | |
| <style> | |
| html { | |
| background: #172033; | |
| color: white; | |
| font: 16px system-ui; | |
| } | |
| body { | |
| margin: 0; | |
| min-height: 150vh; | |
| } | |
| pre { | |
| white-space: pre-wrap; | |
| overflow-wrap: anywhere; | |
| } | |
| main { | |
| padding: calc(env(safe-area-inset-top, 0px) + 16px) 90px 16px 16px; | |
| } | |
| #stripe { | |
| position: fixed; | |
| inset: 0 0 0 auto; | |
| width: 64px; | |
| background: repeating-linear-gradient(45deg, gold 0 12px, black 12px 24px); | |
| } | |
| .marker { | |
| position: fixed; | |
| padding: 12px; | |
| color: black; | |
| font-weight: bold; | |
| } | |
| #edge { | |
| top: 60%; | |
| right: 0; | |
| background: salmon; | |
| } | |
| #safe { | |
| top: 75%; | |
| right: env(safe-area-inset-right, 0px); | |
| background: springgreen; | |
| } | |
| #probe { | |
| visibility: hidden; | |
| position: fixed; | |
| padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) | |
| env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); | |
| } | |
| </style> | |
| <div id="stripe"></div> | |
| <main> | |
| <nav style="display: flex; gap: 14px"> | |
| <a style="color: white" href="cover.html">cover</a | |
| ><a style="color: white" href="auto.html">auto</a | |
| ><a style="color: white" href="contain.html">contain</a> | |
| </nav> | |
| <p>viewport-fit=auto</p> | |
| <h2>Safe-area edge test</h2> | |
| <pre id="result"></pre> | |
| </main> | |
| <div id="edge" class="marker">right: 0 →</div> | |
| <div id="safe" class="marker">right: env(…) →</div> | |
| <div id="probe"></div> | |
| <script> | |
| function measure() { | |
| const s = getComputedStyle(document.getElementById("probe")); | |
| document.getElementById("result").textContent = | |
| "Viewport: " + | |
| innerWidth + | |
| " × " + | |
| innerHeight + | |
| "\nInsets T/R/B/L:\n" + | |
| [s.paddingTop, s.paddingRight, s.paddingBottom, s.paddingLeft].join( | |
| " / ", | |
| ); | |
| } | |
| addEventListener("resize", measure); | |
| visualViewport.addEventListener("resize", measure); | |
| measure(); | |
| </script> |
This file contains hidden or 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> | |
| <meta charset="utf-8" /> | |
| <meta | |
| name="viewport" | |
| content="width=device-width, initial-scale=1, viewport-fit=contain" | |
| /> | |
| <title>Safe-area edge test</title> | |
| <style> | |
| html { | |
| background: #172033; | |
| color: white; | |
| font: 16px system-ui; | |
| } | |
| body { | |
| margin: 0; | |
| min-height: 150vh; | |
| } | |
| pre { | |
| white-space: pre-wrap; | |
| overflow-wrap: anywhere; | |
| } | |
| main { | |
| padding: calc(env(safe-area-inset-top, 0px) + 16px) 90px 16px 16px; | |
| } | |
| #stripe { | |
| position: fixed; | |
| inset: 0 0 0 auto; | |
| width: 64px; | |
| background: repeating-linear-gradient(45deg, gold 0 12px, black 12px 24px); | |
| } | |
| .marker { | |
| position: fixed; | |
| padding: 12px; | |
| color: black; | |
| font-weight: bold; | |
| } | |
| #edge { | |
| top: 60%; | |
| right: 0; | |
| background: salmon; | |
| } | |
| #safe { | |
| top: 75%; | |
| right: env(safe-area-inset-right, 0px); | |
| background: springgreen; | |
| } | |
| #probe { | |
| visibility: hidden; | |
| position: fixed; | |
| padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) | |
| env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); | |
| } | |
| </style> | |
| <div id="stripe"></div> | |
| <main> | |
| <nav style="display: flex; gap: 14px"> | |
| <a style="color: white" href="cover.html">cover</a | |
| ><a style="color: white" href="auto.html">auto</a | |
| ><a style="color: white" href="contain.html">contain</a> | |
| </nav> | |
| <p>viewport-fit=contain</p> | |
| <h2>Safe-area edge test</h2> | |
| <pre id="result"></pre> | |
| </main> | |
| <div id="edge" class="marker">right: 0 →</div> | |
| <div id="safe" class="marker">right: env(…) →</div> | |
| <div id="probe"></div> | |
| <script> | |
| function measure() { | |
| const s = getComputedStyle(document.getElementById("probe")); | |
| document.getElementById("result").textContent = | |
| "Viewport: " + | |
| innerWidth + | |
| " × " + | |
| innerHeight + | |
| "\nInsets T/R/B/L:\n" + | |
| [s.paddingTop, s.paddingRight, s.paddingBottom, s.paddingLeft].join( | |
| " / ", | |
| ); | |
| } | |
| addEventListener("resize", measure); | |
| visualViewport.addEventListener("resize", measure); | |
| measure(); | |
| </script> |
This file contains hidden or 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> | |
| <meta charset="utf-8" /> | |
| <meta | |
| name="viewport" | |
| content="width=device-width, initial-scale=1, viewport-fit=cover" | |
| /> | |
| <title>Safe-area edge test</title> | |
| <style> | |
| html { | |
| background: #172033; | |
| color: white; | |
| font: 16px system-ui; | |
| } | |
| body { | |
| margin: 0; | |
| min-height: 150vh; | |
| } | |
| pre { | |
| white-space: pre-wrap; | |
| overflow-wrap: anywhere; | |
| } | |
| main { | |
| padding: calc(env(safe-area-inset-top, 0px) + 16px) 90px 16px 16px; | |
| } | |
| #stripe { | |
| position: fixed; | |
| inset: 0 0 0 auto; | |
| width: 64px; | |
| background: repeating-linear-gradient(45deg, gold 0 12px, black 12px 24px); | |
| } | |
| .marker { | |
| position: fixed; | |
| padding: 12px; | |
| color: black; | |
| font-weight: bold; | |
| } | |
| #edge { | |
| top: 60%; | |
| right: 0; | |
| background: salmon; | |
| } | |
| #safe { | |
| top: 75%; | |
| right: env(safe-area-inset-right, 0px); | |
| background: springgreen; | |
| } | |
| #probe { | |
| visibility: hidden; | |
| position: fixed; | |
| padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) | |
| env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); | |
| } | |
| </style> | |
| <div id="stripe"></div> | |
| <main> | |
| <nav style="display: flex; gap: 14px"> | |
| <a style="color: white" href="cover.html">cover</a | |
| ><a style="color: white" href="auto.html">auto</a | |
| ><a style="color: white" href="contain.html">contain</a> | |
| </nav> | |
| <p>viewport-fit=cover</p> | |
| <h2>Safe-area edge test</h2> | |
| <pre id="result"></pre> | |
| </main> | |
| <div id="edge" class="marker">right: 0 →</div> | |
| <div id="safe" class="marker">right: env(…) →</div> | |
| <div id="probe"></div> | |
| <script> | |
| function measure() { | |
| const s = getComputedStyle(document.getElementById("probe")); | |
| document.getElementById("result").textContent = | |
| "Viewport: " + | |
| innerWidth + | |
| " × " + | |
| innerHeight + | |
| "\nInsets T/R/B/L:\n" + | |
| [s.paddingTop, s.paddingRight, s.paddingBottom, s.paddingLeft].join( | |
| " / ", | |
| ); | |
| } | |
| addEventListener("resize", measure); | |
| visualViewport.addEventListener("resize", measure); | |
| measure(); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment