Search topics
Modals cut off at the top and bottom when zoomed in
A booking dialog centred with top: 50% and a transform has no height limit, so at 400% zoom it runs past both edges of the window, Close and Confirm included.
transform: translate(-50%, -50%); The problem
People who zoom in can open the booking dialog, but can't reach its Close button or Confirm booking
A bike workshop's page offers a full service for $85, with a Book a service button. The button opens a dialog over the page, dimmed behind it: a × to close it in the top corner, the heading "Book a full service", the date and the price, two short paragraphs about dropping the bike off and changing the booking, and Cancel and Confirm booking at the bottom. On a laptop it sits in the middle of the window with plenty of room around it, and on a phone it fills most of the screen and fits.
Someone with low vision zooms the page to 400% in a window 1280 by 1024 pixels, which leaves it 320 by 256 CSS pixels, and books a service. At that width, with the shop's 16-pixel text and a line height of 1.5, the dialog's text wraps onto more lines and the dialog grows to over 400 pixels tall, in a window 256 tall. It is centred on the window, so more than 80 pixels of it run past the top edge, and as many past the bottom edge: the × and the heading are above the window, and Cancel and Confirm booking below it. The mouse wheel scrolls the page behind, and the dialog doesn't move. Tab reaches Confirm booking, but the button stays out of sight. The only way to book is to zoom back out until the dialog fits.
The dialog is placed with position: fixed, top: 50%, left: 50% and transform: translate(-50%, -50%), a common way to centre a box. It puts the dialog's middle at the window's middle whatever its height, and nothing caps that height at the window's. A fixed box stays where it is when the page scrolls, and this one has no scroll of its own, so what lies past the window's edges can't be brought into view, by the wheel, by touch or by moving focus there. Even the page itself could never scroll to the part above the top edge.
Success criterion 1.4.10 asks that content can be presented without loss of information or functionality at a width of 320 CSS pixels. The Understanding page explains 320 CSS pixels as a window 1280 pixels wide at 400% zoom, and in a window 1024 pixels tall, the same zoom leaves 256 pixels of height. In that window the content is still on the page, drawn past the window's edges, but the person can't reach it: the dialog's heading and its buttons are lost, and so is the booking. The same Understanding page says that moving content is not a loss, so long as people can still get to it: a dialog that scrolls is enough. The closest failure W3C documents is F102, content no longer available after the page has reflowed to 320 pixels.
Anyone whose window is short in CSS pixels, or whose text is large enough to make the dialog taller than the window: zoomed in on a desktop, with a large display size on a phone, with the browser's text size turned up, or on a phone held on its side, where the window is wide but short, and a dialog of ordinary length can run past both edges.
2 of 10 groups affected
- No vision (not affected)
- Low vision (affected)
- Colour vision (not affected)
- No hearing (not affected)
- Hard of hearing (not affected)
- No speech (not affected)
- Motor (affected)
- Reach, strength (not affected)
- Cognitive (not affected)
- Seizures (not affected)
- Limited vision People who zoom the page to 400% get a window 256 CSS pixels tall. The dialog is taller than that, so its heading and Close button sit above the window and its buttons below it, and no scrolling brings them back.
- Limited manipulation Keyboard users who zoom in Tab to Confirm booking and focus lands on a button they can't see, since the browser can't scroll a fixed box. They can't tell where they are or what Enter will do.
Scanners load the page once, at desktop size, and don't open its dialogs; when they do, the dialog fits the window. axe has no rule for it. EaseWeb's audit now looks for it: at 320 by 256 CSS pixels it opens up to eight buttons that are marked as opening something (with aria-haspopup, aria-expanded, aria-controls or popovertarget, for example) or that appear only at that width, and reports a fixed element whose text or controls lie past the top or bottom of the window with nothing around them that scrolls. This page's Book a service button carries none of those marks, so the audit doesn't open it, and a person has to. Design reviews look at the dialog in a laptop frame, where it is short. An AI assistant asked for a centred modal can write this exact transform, with no max-height; react-modal's README shows the same centring as its example of custom styles, and its issue tracker has the question "How to allow scrolling on modal if window is too small".
Try it
Zoom the page to 400%, then book the service
Drag the Zoom slider to 400%, then press Book a service. Can you reach the × that closes the dialog, and Confirm booking, with the mouse wheel or with Tab?
Broken Can you fix this?
Full service
$85
Takes about two hours. Bring the bike in the morning and collect it the same day.
What’s included
- Brakes and gears adjusted
- Wheels trued
- Chain cleaned and oiled
Window: 640 by 512 CSS pixels.
The fix
Let a tall dialog scroll inside the window
<button type="button" id="book">Book a service</button>…<div class="backdrop" hidden> <div class="booking" role="dialog" aria-modal="true" aria-labelledby="booking-title"> <button type="button" class="close" aria-label="Close">×</button> <h2 id="booking-title">Book a full service</h2> <p>Thursday 12 November, 10:00</p> <p>$85, paid when you collect the bike</p> <p>Bring the bike in by 10:00. We’ll email you when it is ready, usually the same afternoon.</p> <p>Plans change? Move or cancel the booking for free up to 24 hours before.</p> <button type="button" class="cancel">Cancel</button> <button type="button" class="confirm">Confirm booking</button> </div></div>What is wrong3 points
At 400% zoom the dialog is over 400 pixels tall, in a window 256 pixels tall.
- The transform centres it on the window, so more than 80 pixels run past the top edge, the × and the heading with them, and as many past the bottom edge, with Cancel and Confirm booking.
- The dialog has no
max-heightand nooverflow, so nothing inside it scrolls. - It is fixed, so scrolling the page moves only the page behind it.
A dialog capped at the window's height
<button type="button" id="book">Book a service</button>…<div class="backdrop" hidden> <div class="booking" role="dialog" aria-modal="true" aria-labelledby="booking-title"> <button type="button" class="close" aria-label="Close">×</button> <h2 id="booking-title">Book a full service</h2> <p>Thursday 12 November, 10:00</p> <p>$85, paid when you collect the bike</p> <p>Bring the bike in by 10:00. We’ll email you when it is ready, usually the same afternoon.</p> <p>Plans change? Move or cancel the booking for free up to 24 hours before.</p> <button type="button" class="cancel">Cancel</button> <button type="button" class="confirm">Confirm booking</button> </div></div>How it is fixed2 steps
- Give the dialog
max-height: calc(100dvh - 2rem). It is never taller than the window less 1rem above and below, and the transform still centres it, so it sits whole inside the window. - Give it
overflow-y: auto. When its content is taller than that, the dialog scrolls: the wheel, touch and the arrow keys move its content, and Tab scrolls each button into view as it takes focus.
This fixes the Before and passes 1.4.10. It is the smallest change, two lines, and the dialog looks the same wherever it fits. At 400% the × and the heading scroll away as the person reads down to the buttons, and back as they scroll up.
All three keep every part of the dialog within reach at 400% zoom, so all three pass 1.4.10. Capping the dialog is the smallest change, two lines on a dialog you already have, and the one to reach for in a component library you can only restyle. Letting the backdrop scroll keeps the dialog's whole shape and moves it as one piece, as a long page would; choose it when the dialog's top and bottom belong together, such as a form whose heading should stay with its first field. The native dialog needs a change to the markup and the script, but its height limit comes from the browser, along with focus held inside and Escape; choose it when you can change the component, and keep its limit when you style it.
A header or footer that stays put inside the dialog, so the × and Confirm booking are always in view while only the middle scrolls, is what Bootstrap's modal-dialog-scrollable and MUI's scroll="paper" do. In a window 256 pixels tall it leaves little room: in a dialog with 1rem of room above and below it, a header and a footer 60 pixels each leave about 100 pixels to read in, and if either wraps onto two rows at 320 pixels wide, the middle can shrink to nothing. If you keep them, keep each to one row at 320 pixels, and in a short window (@media (max-height: 30em)) let the whole dialog scroll instead.
Centring a dialog in an overlay that scrolls needs care. With display: flex and align-items: center on the overlay, a dialog taller than the window is centred by overflowing at both ends, and the overlay can only scroll down, so its top stays cut off. Chakra UI's issue tracker has a report of its centred modal cut off at the top on phones. margin: auto, a grid, or align-items: safe center start the dialog at the top when it doesn't fit.
The same failure reaches other things that float.
- a menu fixed below a header, or a drawer fixed to one side with
top: 0andbottom: 0, which needs its ownoverflow-y: autoto show its last links; - a sheet that slides up from the bottom of the window, which needs a
max-heightand a scroll as the dialog does; - a popover opened with the
popoverattribute, which the browser centres withoverflow: autobut, unlike a modal dialog, gives nomax-height, so a tall one runs past both edges.
A bar fixed to the bottom of the page is a different case: it fits, but covers the page under it, as in floating buy bars that cover the page when zoomed in.
100dvh is the window's height as it is now. On a phone, 100vh is the height with the browser's address bar put away, so a dialog capped at 100vh can still run under the bar until it is scrolled away; in a desktop browser at 400% the two are the same. On a fixed element, max-height: calc(100% - 2rem) works as well, because its percentages are taken from the window, unless an element around it has a property that changes that, such as a transform or a filter.
Locking the page's own scroll while the dialog is open, with overflow: hidden on body, doesn't change any of this: the dialog has to scroll by itself either way. overscroll-behavior: contain on the box that scrolls stops the page behind from moving when the dialog reaches its end.
Verify the fix
5 checks, no mouse.
Test with: Zoom, Keyboard
Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the dialog's component or styles change.
Limits
This is a starting pattern, not a guarantee for every application. The sizes are this example's; test your own dialogs with their longest content. A dialog that fits the window but is wider than 320 pixels, so the page scrolls sideways, is a different failure, covered in pages that scroll sideways on a narrow screen. A sticky header that hides the control in focus is covered in sticky headers and banners that hide keyboard focus. Passing at 400% doesn't make a long dialog easy to use there: a dialog that needs several screens to read may be better as a page of its own. Class names in the snippets are placeholders for your own.
This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.
References
EaseWeb service
Fixed it? Keep it from coming back.
I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.