How to implement vertical text alignment with CSS (Summary)

How to implement vertical text alignment with CSS (Summary)

The default arrangement of text in HTML is horizontal, but in some special cases, the text needs to be arranged vertically.

Single line text vertical arrangement

.onecn{
     width: 20px;  
    margin: 0 auto;  
    line-height: 24px;  
} 

.oneen{
    width: 15px;
    margin: 0 auto;
    line-height: 24px;
    font-size: 20px;
    word-wrap: break-word;/*You need to add this sentence when writing in English to automatically wrap the line*/
    word-break:break-all;
}

Note: To arrange text in a single line vertically, you only need to set the width to just accommodate one font.

Multiple lines of text arranged vertically

.two{
      margin: 0 auto;
      height: 140px;
      writing-mode: vertical-lr;/*From left to right and from right to left is writing-mode: vertical-rl;*/ 
    writing-mode: tb-lr;/*IE browser's left to right and right to left is writing-mode: tb-rl;*/
  }

Note: Height is very important. If you need to control the spacing between text and lines, you can add the attributes letter-spacing and line-height.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  How to install redis in Docke

>>:  9 Practical Tips for Creating Web Content Pages

Recommend

Solution to the problem that the Vue page image does not display

When making a new version of the configuration in...

A brief talk about JavaScript Sandbox

Preface: Speaking of sandboxes, our minds may ref...

In-depth analysis of JDBC and MySQL temporary tablespace

background Temporary tablespaces are used to mana...

Tips for viewing text in Linux (super practical!)

Preface In daily development, we often need to pe...

Detailed explanation of Vue development website SEO optimization method

Because the data binding mechanism of Vue and oth...

How to use JS to parse the excel content in the clipboard

Table of contents Preface 1. Paste Events and Cli...

Methods for defragmenting and reclaiming space in MySQL tables

Table of contents Causes of MySQL Table Fragmenta...

Solution to the IP address not being displayed under Linux

Table of contents Preface Solution: Step 1 Step 2...

How to run Python script on Docker

First create a specific project directory for you...

How to create and run a Django project in Ubuntu 16.04 under Python 3

Step 1: Create a Django project Open the terminal...

Vue implements the function of calling the mobile phone camera and album

This article shares the specific code of Vue to a...

js to implement the snake game with comments

This article example shares the specific code of ...