How to make div text vertical in css

藏色散人
Release: 2023-01-03 09:24:42
Original
6223 people have browsed it

How to make div text vertical in css: first create an HTML sample file; then create a div; finally, set the css style to "div{writing-mode: tb-rl;}" to make it vertical. The div text is vertical.

How to make div text vertical in css

The operating environment of this article: Windows7 system, HTML5&&CSS3, Dell G3 computer.

How to set text to be arranged vertically in css:

1. Writing-mode (setting the writing direction of the object)

Syntax: writing-mode: lr-tb, tb-rl

Parameters: lr-tb: left to right, top to bottom tb-rl: top to bottom, right to left

Example:

css code:

div { writing-mode: tb-rl; }
Copy after login

Example:

<!DOCTYPE html>    
<html>    
<head>    
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />    
<title>竖列排版实例</title>    
<style>    
div { writing-mode: tb-rl; }  
</style>    
</head>    
<body>   
<div>我是竖列排版</div>   
</body>    
</html>
Copy after login

Rendering:

How to make div text vertical in css

##2. Common layout ideas: Setting the width of the text object can only arrange the width distance of the next text. If the text cannot fit two characters in one line, the text will automatically wrap, which creates the need for vertical typesetting.

<!DOCTYPE html>    
<html>    
<head>    
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />    
<title>竖列排版实例</title>    
<style>    
body{text-align:center}    
.shuli{ margin:0 auto;width:20px;line-height:24px;border:1px solid #333}    
</style>    
</head>    
<body>   
<div class="shuli">我是竖列排版</div>   
</body>    
</html>
Copy after login
Rendering:

How to make div text vertical in css

Recommended: "

css video tutorial"

The above is the detailed content of How to make div text vertical in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template