Menu

Post image 1
Post image 2
1 / 2
0

New Units of Measurement in CSS (dvh, lvh, svh) and Why Its Time to Forget About vh

DEV Community·Nick Benksim·about 1 month ago
#kFNooZHm
Reading 0:00
15s threshold

The Evolution of CSS Units: Why It’s Time to Retire vh For a long time, mobile interface layout was a real headache for frontend developers. The problem was the unstable behavior of the vh (viewport height) unit. When mobile browsers hide or show toolbars (the address bar or navigation), the viewport height changes, leading to content “jumping” and blocks being cut off. Fortunately, the CSS specification brought a solution — new dynamic units: dvh , lvh , and svh . What Was the Problem with vh? The 1vh unit was originally intended to be 1% of the viewport height. However, on mobile devices, “viewport height” is a flexible concept. There are three browser states: Minimal state: when the address bar is expanded. Maximal state: when the address bar is hidden. Intermediate state: during scrolling. In most browsers, vh was tied to either the maximum or minimum value, without responding to interface changes.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More