search
HomeWeb Front-endCSS TutorialWriting-mode text display direction and compatible writing methods in css

The

writing-mode of css is said to be designed for square text such as Chinese and Japanese. It is used to modify the writing direction of the text. Through this attribute, the text can be laid out from right to left, or from top to bottom. Downward layout.

writing-mode using

.wrtmod{
    margin:15px;
    padding:15px;
    border:1px solid #bababa;
    background:#f1f1f1;
    font-size:15px;
    writing-mode:vertical-rl;
    writing-mode: tb-rl;
}

The effect is as follows:

chrome browser:

Writing-mode text display direction and compatible writing methods in css

IE Browser:

Writing-mode text display direction and compatible writing methods in css

The attribute values ​​​​of writing-mode are: horizontal-tb, vertical-lr, vertical-rl, corresponding The values ​​under IE are: lr-tb, tb-lr, tb-rl.

horizontal-tb is the default value. The attribute value of writing-mode is separated by a dash and can be recorded as XX-OO. horizontal-tb means that the text is arranged horizontally and the lines are arranged up and down. veritcal-rl means that the text is arranged up and down and the lines are arranged from right to left. IE's lr-tb means that the text is arranged from left to top, and the lines are arranged from top to bottom. tb-rl means that the text is arranged from top to bottom, and the lines are arranged from top to left. lr is the abbreviation of left and right, and tb is the abbreviation of top and bottom. You can also use attribute values ​​such as bt-rl, lr-bt under IE, and the arrangement methods are more abundant. However, for compatibility, only these three arrangements can be used in the writing-mode attribute.

From the screenshot above, we can see that writing-mode not only changes the writing direction of the text, but also changes the layout of the container. The div in chrome and FireFox browsers has the inline feature.

The entire div in the IE8 browser changes from horizontal to vertical, and has a highly adaptive feature.

The purpose of writing-mode is generally used in the vertical display of some poems, or on some pages with retro effects. However, it should be noted that IE8 is different from other browsers. It does not have the feature of inline, so we To achieve the effect under IE through display:inline-block.

.wrtmod{
    margin:15px;
    padding:15px;
    border:1px solid #bababa;
    background:#f1f1f1;
    font-size:15px;
    writing-mode:vertical-rl;
    writing-mode:tb-rl;
    text-align:center;
    line-height:32px;
    letter-spacing: 12px;
    display: inline-block;
 
}
.wrtmod:first-line{
    font-weight:bold;
    color:#0C58A7;
    font-size:18px;
}
 
<div class="wrtmod">
    静夜思<br/>
    窗前明月光<br/>
    疑是地上霜<br/>
    举头望明月<br/>
    低头思故乡
</div>

The effect is as follows:

Writing-mode text display direction and compatible writing methods in css

writing-modeAfter changing the writing mode, use text-align:center to achieve top and bottom centering. The above effect uses letter-spacing and ::first-line pseudo-classes, combined with write-mode, to achieve the writing effect of an ancient poem.

The above is the detailed content of Writing-mode text display direction and compatible writing methods in css. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Iterating a React Design with Styled ComponentsIterating a React Design with Styled ComponentsApr 21, 2025 am 11:29 AM

In a perfect world, our projects would have unlimited resources and time. Our teams would begin coding with well thought out and highly refined UX designs.

Oh, the Many Ways to Make Triangular Breadcrumb Ribbons!Oh, the Many Ways to Make Triangular Breadcrumb Ribbons!Apr 21, 2025 am 11:26 AM

Oh, the Many Ways to Make Triangular Breadcrumb Ribbons

SVG Properties in CSS GuideSVG Properties in CSS GuideApr 21, 2025 am 11:21 AM

SVG has its own set of elements, attributes and properties to the extent that inline SVG code can get long and complex. By leveraging CSS and some of the forthcoming features of the SVG 2 specification, we can reduce that code for cleaner markup.

A Few Functional Uses for Intersection Observer to Know When an Element is in ViewA Few Functional Uses for Intersection Observer to Know When an Element is in ViewApr 21, 2025 am 11:19 AM

You might not know this, but JavaScript has stealthily accumulated quite a number of observers in recent times, and Intersection Observer is a part of that

Revisting prefers-reduced-motionRevisting prefers-reduced-motionApr 21, 2025 am 11:18 AM

We may not need to throw out all CSS animations. Remember, it’s prefers-reduced-motion, not prefers-no-motion.

How to Get a Progressive Web App into the Google Play StoreHow to Get a Progressive Web App into the Google Play StoreApr 21, 2025 am 11:10 AM

PWA (Progressive Web Apps) have been with us for some time now. Yet, each time I try explaining it to clients, the same question pops up: "Will my users be

The Simplest Ways to Handle HTML IncludesThe Simplest Ways to Handle HTML IncludesApr 21, 2025 am 11:09 AM

It's extremely surprising to me that HTML has never had any way to include other HTML files within it. Nor does there seem to be anything on the horizon that

Change Color of SVG on HoverChange Color of SVG on HoverApr 21, 2025 am 11:04 AM

There are a lot of different ways to use SVG. Depending on which way, the tactic for recoloring that SVG in different states or conditions — :hover,

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment