jcrabapple/hermes-skills/mobile-viewport-fit

Claude Code and agent skill by jcrabapple/hermes-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Make full-screen web apps (game boards, tools with fixed header + flexible content + fixed keyboard/footer) fit on mobile without scrolling. Solves the common problem where 100vh includes the browser address bar area on mobile, causing content to overflow below the visible viewport.

Install

npx vskill@latest install jcrabapple/hermes-skills/mobile-viewport-fit

SKILL.md

The same SKILL.md was published earlier as jcrabapple/hermes-skills/mobile-viewport-fit.

Mobile Viewport Fit

The Problem

On mobile browsers, 100vh includes the area behind the URL/address bar. The visible area is smaller, so content sized to 100vh overflows and requires scrolling. This is especially bad for game UIs (Wordle clones, keyboards, calculators) where all controls must be visible at once.

The Fix Pattern

1. Body: Lock to Dynamic Viewport Height
css
body {
display: flex;
flex-direction: column;
height: 100vh; /* fallback for older browsers */
height: 100dvh; /* dynamic viewport height — excludes address bar */
overflow: hidden; /* hard prevent scrolling */
}

100dvh = the actual visible area. 100vh is kept as fallback since dvh isn't supported everywhere yet.

2. Fixed Elements: No Shrink

Header and keyboard/footer must not shrink — they always get their full size:

css
header, #keyboard {
flex-shrink: 0;
}
3. Flexible Content: Takes Remaining Space

The game board / main content area gets whatever space is left:

css
#board {
flex: 1 1 0; /* grow, shrink, from zero */
min-height: 0; /* allow shrinking below content size */
overflow: hidden;
justify-content: center;
}

min-height: 0 is critical — without it, flex items won't shrink below their content's intrinsic size.

4. Dynamic Sizing for Content Tiles/Cells

CSS alone can't make fixed-size elements shrink to fit a flex container's computed height. Use JS to measure available space and set CSS custom properties:

js
function fitBoard() {
const board = document.getElementById('board');
if (!board) return;
const availH = board.clientHeight;
const gap = parseFloat(getComputedStyle(board).gap) || 5;
const padTop = parseFloat(getComputedStyle(board).paddingTop) || 0;
const padBot = parseFloat(getComputedStyle(board).paddingBottom) || 0;
const rows = 6;
const usable = availH - padTop - padBot - (rows - 1) * gap;
const cellH = Math.floor(usable / rows);
const clamped = Math.min(58, Math.max(32, cellH));
document.documentElement.style.setProperty('--cell-size', clamped + 'px');
document.documentElement.style.setProperty('--cell-font', Math.floor(clamped * 0.52) + 'px');
}
window.addEventListener('resize', fitBoard);
window.addEventListener('DOMContentLoaded', () => setTimeout(fitBoard, 0));

Then in CSS:

css
.tile {
width: var(--cell-size, 58px);
aspect-ratio: 1;
font-size: var(--cell-font, 30px);
}

Fallback values in var() ensure it works before JS runs.

5. Media Queries: Shrink Gaps and Fixed Elements

Use max-height media queries to reduce keyboard key heights and gaps on short viewports:

css
@media (max-height: 700px) {
header { padding: 6px 16px; }
.key { height: 44px; min-width: 26px; font-size: 12px; }
#keyboard { padding: 4px 6px 8px; gap: 4px; }
.kb-row { gap: 3px; }
}

Do NOT override the dynamic tile sizes in media queries — the JS handles that based on actual available space.

Common Mistakes

  • Setting tile sizes in media queries — these fight with JS dynamic sizing.

Let JS handle tile dimensions; only adjust gaps/padding/keyboard in MQs.

  • Using `min-height: 100vh` on body — allows the page to grow beyond

the viewport. Use fixed height: 100dvh instead.

  • Forgetting `min-height: 0` on flex child — without it, the board won't

shrink below its content's intrinsic size even with flex-shrink.

  • Forgetting `flex-shrink: 0` on header/keyboard — they'll compress

and become unusable.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/jcrabapple/hermes-skills/mobile-viewport-fit/badge)](https://verified-skill.com/skills/jcrabapple/hermes-skills/mobile-viewport-fit)

Something wrong with this skill or its page? Tell us.