I'm creating a Wordle like app with an on-screen keyboard. When developing on desktop and using dev tools to simulate a mobile screen, it looks fine. But when I view the site on my iPhone (Safari and Chrome), the keyboard is too wide and is cut off.
I checked on an android device in Chrome and, again, it looks fine.
I'm developing in Svelte, here is my relevant code:
<script lang="ts">
import Key from './Key.svelte';
const lets = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'];
</script>
<div class="keyboard">
{#each lets as row, i}
{#if i === 2}
<div class="row"
<Key letter="enter" />
{#each row as letter}
<Key {letter} />
{/each}
<Key letter="del" />
</div>
{:else}
<div class="row">
{#each row as letter}
<Key {letter} />
{/each}
</div>
{/if}
{/each}
</div>
<style>
.keyboard {
display: flex;
flex-direction: column;
gap: 6px;
margin: 0 8px;
height: 200px;
max-width: 100vw;
}
.row {
display: flex;
justify-content: center;
gap: 6px;
max-width: 100vw;
touch-action: manipulation;
margin: 0 auto 8px;
}
</style>
And here is Key.svelte:
<script lang="ts">
export let letter: string;
</script>
<button>{letter}</button>
<style>
button {
background-color: rgb(152, 152, 152);
display: flex;
justify-content: center;
align-items: center;
color: white;
border-radius: 4px;
height: 58px;
cursor: pointer;
border: none;
font-family: 'Nanum Pen Script', cursive;
font-size: 22px;
text-transform: uppercase;
user-select: none;
}
</style>
