Use responsive layouts and logical properties
Respond to available space
Responsive layout adapts to space instead of assuming every user has a wide screen. A viewport media query tests the viewport; a container query tests an eligible ancestor container. Start with one column, then add a second when the exhibit area has room. Use the following App.jsx and layout.css together. The second JSX example is an alternative App.jsx using the same stylesheet.
import React from 'react';import './layout.css';export default function App() { return <main className="exhibit"><h1>Exhibits</h1><section className="catalog" aria-label="Exhibit list"> <article><h2>River stones</h2><p>Gallery A</p></article> <article><h2>Forest seeds</h2><p>Gallery B</p></article> </section></main>;}* { box-sizing: border-box; }.exhibit { container-type: inline-size; }.catalog { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }.catalog article { min-inline-size: 0; overflow-wrap: anywhere; border: 1px solid #64748b; padding: 1rem; border-inline-start: 4px solid #1d4ed8; }@container (min-width: 36rem) { .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); } }.nav { display: flex; flex-wrap: wrap; gap: .75rem; }.search { display: grid; gap: .5rem; }.search input { min-inline-size: 0; max-inline-size: 100%; }@media (min-width: 48rem) { .search { grid-template-columns: 1fr auto; align-items: end; } }At a container width below 36rem the grid has one column; at or above the threshold it has two, assuming horizontal writing mode. The container is the parent, not the grid itself. minmax(0, 1fr) allows tracks to shrink; min-inline-size and overflow-wrap help long content fit. The border-inline-start switches physical side when direction changes. Prefer padding-inline and margin-block when spacing follows reading direction. A container query is not a React Hook or a screen-size listener.
Let navigation and forms wrap
import React, { useState } from 'react';import './layout.css';export default function App() { const [query, setQuery] = useState(''); const [submitted, setSubmitted] = useState(''); return <main><nav className="nav" aria-label="Gallery"><a href="#exhibits">Exhibits</a><a href="#visit">Visit</a></nav> <form className="search" onSubmit={e => {e.preventDefault(); setSubmitted(query.trim());}}> <label>Filter exhibits <input value={query} onChange={e => setQuery(e.target.value)} /></label><button>Apply</button> </form><section id="exhibits"><h2>Exhibits</h2><p role="status">Filter: {submitted || 'All'}</p></section> <section id="visit"><h2>Visit</h2><p>Gallery A and B</p></section></main>;}The navigation wraps naturally; the form switches from a vertical layout to two columns at a viewport of 48rem. Submitting displays the trimmed filter text; this teaching fixture does not actually filter a dataset. Keep semantic links for navigation and a native button for submission. DOM order remains reading and tab order; avoid visual reordering that creates a confusing focus sequence. Test narrow widths, zoom, long content and dir="rtl" with English synthetic text. A browser CSS test is separate from React interaction tests.
Practice
Change the exhibit container width without changing the viewport. Predict the grid layout before testing it. Then toggle dir on the wrapper and inspect the border side. Make sure a long word does not push the page beyond the viewport.