Skip to content
Tech News
← Back to articles

Designing for Dual Screen and Foldable Devices with CSS (2023)

read original get Google Pixel Fold → more articles
Why This Matters

As foldables like Google's Pixel Fold enter the mainstream, web developers need practical tools to adapt layouts across hinged, multi-segment screens. This piece shows those tools already exist in CSS — viewport-segment media queries and environment variables — so sites can respond to fold geometry without hard-coding per-device designs.

Key Takeaways
Worth a Look

Google Pixel Fold — If you want to actually test those horizontal- and vertical-viewport-segment media queries, nothing beats having a real foldable in hand. The Pixel Fold gives you both the book-style side-by-side layout and the laptop-style stacked mode the article describes, so you can see your CSS env() fold geometry work in the wild.

See Google Pixel Fold on Amazon → Affiliate link — we may earn a commission on purchases, at no extra cost to you. Product picked by AI based on this article; it is not a tested recommendation.

Designing for Dual Screen and Foldable Devices With CSS

With the announcement of Google's Pixel Fold, I thought its an apt time to revisit what technologies are available for designing and developing experiences that adapt to a foldable device.

Let's ignore the naysayers who vehemently don't want to design for a new form factor, while also ignoring the price of Goggle's first generation device and just focus on what's possible right now.

CSS Media Queries for Viewport Segments #

There are two media queries for targeting your foldable device.

@media (horizontal-viewport-segments: <count>) { } @media (vertical-viewport-segments: <count>) { }

The horizontal-viewport-segments query targets the device when it is being held like a book and the two screens are side-by-side.

And vertical-viewport-segments targets the device when the two screens are stacked on top of each other and fold like a laptop. I've found this mode useful when using my Surface Duo with PowerPoint. I can access my speaker notes on the bottom screen and my presentation is on the top screen. Pretty snazzy.

CSS Environment Variables #

In order to get the geometry of each display, a handful of environment variables have been created for dual screen devices.

... continue reading