Viewport units can consider the writing mode (#tilPost)

Slowly but surely, developers adopt logical CSS properties to be good web citizens and write CSS that follows a defined writing mode, directionality, and text orientation.
width becomes inline-size, margin-inline is a shorthand for …


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis

Slowly but surely, developers adopt logical CSS properties to be good web citizens and write CSS that follows a defined writing mode, directionality, and text orientation.

width becomes inline-size, margin-inline is a shorthand for margin-left and margin-right, you get the idea.

MDN lists all the logical CSS properties if you haven't heard about them yet.

That's all good and dandy, but there's at least one situation where logical CSS properties aren't enough. Suppose you want to style a container and make it 50% of the viewport on the horizontal axis.

You can define inline-size: 50vw; but isn't that mixing things up? inline-size will define either the horizontal or vertical size depending on the writing mode, but 50vw will always be the viewport width.

I don't know if that's a real issue because I can't read languages that go from top to bottom, let alone build a website. But I can imagine that writing mode dependent viewport units can be handy!

And today I learned these viewport units exist! vi and vb consider writing direction!

vi is the percentage of the initial containing blocks inline axis and vb the percentage of the block axis. 🤯

In left-to-right
vi -> vw
vb -> vh

---

In top-to-bottom
vi -> vh
vb -> vw

That's confusing stuff, so I build a component to learn how this works!

[Interactive component: visit the article to see it...]

What's the browser support? Chrome started supporting these units not very long ago.

MDN Compat Data (source)
Browser support info for vi unit
chrome chrome_android edge firefox firefox_android safari safari_ios samsunginternet_android webview_android
108 108 108 101 101 15.4 15.4 108

I'm no expert in languages other than German and English, but are people building Asian websites ecstatic about these units and that they're almost cross-browser supported at the time I'm publishing this article?

If you know more about it, I'd love to hear more!


Reply to Stefan


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis


Print Share Comment Cite Upload Translate Updates
APA

Stefan Judis | Sciencx (2022-12-21T23:00:00+00:00) Viewport units can consider the writing mode (#tilPost). Retrieved from https://www.scien.cx/2022/12/21/viewport-units-can-consider-the-writing-mode-tilpost/

MLA
" » Viewport units can consider the writing mode (#tilPost)." Stefan Judis | Sciencx - Wednesday December 21, 2022, https://www.scien.cx/2022/12/21/viewport-units-can-consider-the-writing-mode-tilpost/
HARVARD
Stefan Judis | Sciencx Wednesday December 21, 2022 » Viewport units can consider the writing mode (#tilPost)., viewed ,<https://www.scien.cx/2022/12/21/viewport-units-can-consider-the-writing-mode-tilpost/>
VANCOUVER
Stefan Judis | Sciencx - » Viewport units can consider the writing mode (#tilPost). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/12/21/viewport-units-can-consider-the-writing-mode-tilpost/
CHICAGO
" » Viewport units can consider the writing mode (#tilPost)." Stefan Judis | Sciencx - Accessed . https://www.scien.cx/2022/12/21/viewport-units-can-consider-the-writing-mode-tilpost/
IEEE
" » Viewport units can consider the writing mode (#tilPost)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2022/12/21/viewport-units-can-consider-the-writing-mode-tilpost/. [Accessed: ]
rf:citation
» Viewport units can consider the writing mode (#tilPost) | Stefan Judis | Sciencx | https://www.scien.cx/2022/12/21/viewport-units-can-consider-the-writing-mode-tilpost/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.