From 3f6a9546ec13063d0d5bdf21d30a93d3e8aa6050 Mon Sep 17 00:00:00 2001 From: Bradley Taunt Date: Tue, 2 Jul 2024 14:22:21 -0400 Subject: Rebuild changes based off latest barf --- build/dv/index.html | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 build/dv/index.html (limited to 'build/dv/index.html') diff --git a/build/dv/index.html b/build/dv/index.html new file mode 100644 index 0000000..e17e3cd --- /dev/null +++ b/build/dv/index.html @@ -0,0 +1,73 @@ + + + + + + + + Dynamic Viewports with CSS + + + + + + + +
+

Dynamic Viewports with CSS

+

2023-02-08

+

I think it’s safe to assume most web designers and developers are familiar with the standard vh and vw parameters in CSS. These parameters are used for setting an element’s height and/or width, relative to the viewport (v) height (h) or width (w). For example:

+

If I want my .box element to take up the entire height of a device’s screen:

+
.box {
+    height: 100vh;
+}
+
+

Or I want my .box element to take up the entire width of a device’s screen:

+
.box {
+    width: 100vw;
+}
+
+

These are wonderful options to have - specifically for those of us designing web applications. But there are some minor issues with vh and vw.

+
    +
  1. The setting does not take into account device-specific UI (status bars, toolbars, search fields etc.)
  2. +
  3. In some instances these will not play nice with box-sizing properties
  4. +
+

Have No Fear, Dynamic Viewport is Here!

+

Lucky for us there exists an awesome new-ish CSS API called dynamic viewport-percentage units: dvh & dvw. They are defined as follows:

+
+

The dynamic viewport-percentage units (dv) are defined with respect to the dynamic viewport size: the viewport sized with dynamic consideration of any UA interfaces that are dynamically expanded and retracted. This allows authors to size content such that it can exactly fit within the viewport whether or not such interfaces are present.

+
+

So our examples above would translate into:

+
.box {
+    height: 100dvh;
+    width: 100dvw;
+}
+
+

What About Browser Support?

+

Can I Use Stats / ~67.17% coverage.

+

Note: Even though the caniuse page states that Firefox 109+ and iOS Safari 16.3 do not support dvh, in my experiments they do. I’m not sure what testing was done for those two browsers, so YMMV.

+

If you want to play it safe, use dynamic viewports with standard “traditional” viewports as backup. That way you support all use cases while still taking advantage of newer CSS properties.

+ \ No newline at end of file -- cgit v1.2.3-54-g00ecf