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

translate(-50%,-50%) in CSS achieves horizontal and vertical centering effect

translate(-50%,-50%) attributes: Move it up and l...

Detailed explanation of putting common nginx commands into shell scripts

1. Create a folder to store nginx shell scripts /...

Detailed explanation of how to install MariaDB 10.2.4 on CentOS7

CentOS 6 and earlier versions provide MySQL serve...

How to use dl(dt,dd), ul(li), ol(li) in HTML

HTML <dl> Tag #Definition and Usage The <...

Theory Popularization——User Experience

1. Concept Analysis 1: UE User Experience <br ...

Introduction to vim plugin installation under Linux system

Table of contents Install vim plugin manager Add ...

Sample code for implementing follow ads with JavaScript

Floating ads are a very common form of advertisin...

Detailed explanation of scheduled tasks for ordinary users in Linux

Preface Ordinary users define crontab scheduled t...

Detailed example of using js fetch asynchronous request

Table of contents Understanding Asynchrony fetch(...

Solution to failure in connecting to mysql in docker

Scenario: After installing the latest version of ...

MySQL Basics in 1 Hour

Table of contents Getting Started with MySQL MySQ...

Install Python 3.6 on Linux and avoid pitfalls

Installation of Python 3 1. Install dependent env...

An article teaches you to write clean JavaScript code

Table of contents 1. Variables Use meaningful nam...

A brief analysis of HTML space code

How much do you know about HTML? If you are learni...

Organize the common knowledge points of CocosCreator

Table of contents 1. Scene loading 2. Find Node 1...