惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
L
LINUX DO - 最新话题
P
Proofpoint News Feed
Cyberwarzone
Cyberwarzone
Know Your Adversary
Know Your Adversary
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
Lohrmann on Cybersecurity
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Security Latest
Security Latest
T
The Exploit Database - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy & Cybersecurity Law Blog
K
Kaspersky official blog
The Last Watchdog
The Last Watchdog
Webroot Blog
Webroot Blog
Scott Helme
Scott Helme
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
WordPress大学
WordPress大学
L
LINUX DO - 热门话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
V
Visual Studio Blog
O
OpenAI News
AI
AI
Hacker News: Ask HN
Hacker News: Ask HN
V2EX - 技术
V2EX - 技术
GbyAI
GbyAI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Simon Willison's Weblog
Simon Willison's Weblog
S
Schneier on Security
Spread Privacy
Spread Privacy
Y
Y Combinator Blog
I
InfoQ
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
F
Fortinet All Blogs
C
CERT Recently Published Vulnerability Notes
T
The Blog of Author Tim Ferriss
C
Check Point Blog
Apple Machine Learning Research
Apple Machine Learning Research
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
N
News and Events Feed by Topic
Project Zero
Project Zero
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
B
Blog
G
Google Developers Blog

Ahmad Shadeed

Better fluid sizing with round() Use Cases for Field Sizing The Basics of Anchor Positioning Item Flow CSS Relative Colors Balancing Text In CSS Should masonry be part of CSS grid? CSS display contents CSS Grid Areas CSS Cap Unit An Interactive Guide to CSS Container Queries CSS :has() Interactive Guide CSS Nesting UX in DevTools CSS Nesting Future CSS: State Container Queries Rebuilding a comment component with modern CSS Conditional CSS with :has and :nth-last-child CSS Text balancing with text-wrap:balance CSS Masking Do we need CSS flex-wrap detection? My CSS Wishlist Conditional CSS CSS Style Queries Inside the mind of a frontend developer: Article layout Inside the mind of a frontend developer: Hero section CSS container queries are finally here The CSS behind Figma First Look At The CSS object-view-box Property Learn CSS Subgrid CSS :has Parent Selector Aligning Content In Different Wrappers Flexbox Dynamic Line Separator Hello, CSS Cascade Layers Building UI Components With SVG and CSS A Deep CSS Dive Into Radial And Conic Gradients Defensive CSS Building Real-life Components: Facebook Messenger Conditional Border Radius In CSS CSS Container Query Units Less Absolute Positioning With Modern CSS Aligning a Button Label Vertically Comparing Design Mockups To Code Result Using HSL Colors In CSS Custom Scrollbars In CSS Let CSS Container Queries For Designers The State of CSS Cross-Browser Development Overflow Issues In CSS Inspect Element As A Way To Increase Your Curiosity Handling Text Over Images in CSS Digging Into CSS Logical Properties Clipping Scrollable Areas On The inline-start Side Understanding Clip Path in CSS The Art of Building Real-life Components Handling Short And Long Content In CSS CSS Scroll Snap A Deep Dive Into CSS Grid minmax() CSS Variables 101 Finding The Root Cause of a CSS Bug Learn CSS centering How to detect browser support for Flexbox Gap CSS Mistakes While On Autopilot Digging Into the Flex Property Understanding CSS Multiple Backgrounds Aligning Logo Images in CSS Grid for layout, Flexbox for components Colors in CSS Thinking About The In-between Design Cases min(), max(), and clamp() CSS Functions Image Techniques On The Web Everything About Auto in CSS Learn Box Alignment Let Learn CSS Positioning Intrinsic Sizing In CSS CSS Grid Template Areas In Action Hiding Elements On The Web Creating a Variable Color Font From Scratch Building a Football Ticket With CSS and SVG Blending Modes in CSS CSS Variables With Inline Styles Implementing Dark Mode For My Website Rebuilding Apple Music Header in HTML & CSS Accessible Checkbox Layout Flickering On Browser Resize Enhancing The Clickable Area Size Custom Underlines with SVG Part 3: The Process of Implementing A UI Design From Scratch Part 2: The Process of Implementing A UI Design From Scratch Building An Old Nav Design CSS Flexbox: 5 Real World Use Cases I Used CSS Inline Flex For The First Time The Process of Implementing A UI Design From Scratch Common CSS Issues For Front-End Projects Handling Long and Unexpected Content in CSS How to Build Web Form Layouts With CSS Grid Grid Layout Ah-ha Moment Enhancing Our Components with CSS :empty Building Resizeable Components with Relative CSS Units The Journey of Learning Front End Web Development on a Daily Basis
CSS Writing Mode
Ahmad Shadeed · 2016-07-28 · via Ahmad Shadeed

The Layout Maestro

I spent years teaching CSS layout on this blog. I put everything I know into The Layout Maestro course: 70+ lessons and 150+ interactive examples that teach you how to think CSS layouts, not just memorize syntax.

Get the course

Recently, while editing some CSS in Opera inspector, I noticed a CSS property called writing-mode, that was the first time I knew of it. After some research, I learned that its purpose is for vertical language scripts, like Chinese or Japanese. However, the interesting thing is that when using it with English, we can create a vertical text very easily.

The writing-mode property defines whether lines of text are laid out horizontally or vertically and the direction in which blocks progress. As of MDN

The default writing mode

Browser agents that support this propery will have horizontal-tb as the default value. This works for horizontal language scripts like: English, French, Arabic.. etc

We will explore the value of vertical-lr, lr stands for (Left to right).

Example 1

In the above design, we have a section title that is rotated 90deg around the top left of it’s origin. If you want to do this without CSS writing-mode, we need to do the following:

  1. Create a positioning context for the wrapper element by adding position:relative.
  2. Position the title absolutely by adding position: absolute.
  3. Change the transform origin based on how we want to rotate it. In our case we want to change it to the top left corner, so we add transform-origin: left top.
  4. Rotate the title by adding transform: rotate(90deg).
  5. Finally, we need to add some padding on the left side of the wrapper element in order to prevent the overlap between the section title and grid items.

{% highlight html %}

Our Works

{% endhighlight %}

{% highlight css %} .wrapper { position: relative; padding-left: 70px; }

.section-title { position: absolute; left: 0; transform-origin: left top; transform: rotate(90deg); } {% endhighlight %}

A lot of work to do for such design, right? Lets explore how this could be done using CSS writing-mode:

{% highlight css %} .section-title { writing-mode: vertical-lr; } {% endhighlight %}

We’re done! :D As you see, there is no need to position anything or add padding as we did. Checkout the demo below:

Example 2

With the above design, we have a sharing widget that is placed vertically beside the content. It’s true that we can make this easily without CSS writing-mode, but the interseting thing is that when using it with the social widget, we will get the ability to vertically center it (left, center or right).

As in the example, the social widget is vertically aligned to the top of its parent. By changing CSS text-align propery, we can change the position of it. For example:

{% highlight css %} .social-widget { writing-mode: vertical-lr; text-align: right; } {% endhighlight %}

This will align it to the bottom of it’s parent! Easy, right? In the next example, it will be centered vertically.

{% highlight css %} .social-widget { writing-mode: vertical-lr; text-align: center; } {% endhighlight %}

And here is the demo for the social widget:

Disclaimer: I stopped using icon fonts and switched to SVG, I’m using the icon fonts for the sake of the demo only.

Browsers Support

The global support is 84.65% and this is really good. You can use the property today in order to get benefit like we did in our examples.

Look at that green! :)

Further reading

{% include share.html text = “CSS Writing Mode” link = “https://ishadeed.com/article/css-writing-mode/” %}

Thank you for reading.