当前位置:网站首页>Several cases of word wrapping in div
Several cases of word wrapping in div
2022-07-29 03:43:00 【Chen Fuguo】
div Chinese word wrapping :
div After setting the width , If div In the middle is Chinese , The default text exceeds div The width will wrap automatically , If it's English , The default is no newline , Will exceed div The width of continues to display . This situation , We need to force line breaks through attribute values
- word-break:break-all; Only for English , Wrap by letter
- word-wrap:break-word; Only for English , Word wrap
- white-space:pre-wrap; Chinese only , Forced line wrap
- white-space:nowrap; Force no wrapping , It all works.
- white-space:nowrap; overflow:hidden; text-overflow:ellipsis; Don't wrap , The excess is hidden and appears as an ellipsis ( Some browsers support )
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style> div{
width: 30px; /* height: 30px; */ border: 1px solid black; margin-top: 20px; } /* Only for English , Wrap by letter */ .p1 {
word-break: break-all; width: 150px; } /*-- Only for English , Word wrap */ .p2 {
word-wrap: break-word; width: 150px; } /* Chinese only , Forced line wrap */ .p3 {
white-space: pre-wrap; width: 150px; } /* Force no wrapping , It all works. */ .p4 {
white-space: nowrap; width: 10px; } /* Don't wrap , The excess is hidden and appears as an ellipsis */ .p5 {
white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100px; } </style>
</head>
<body>
<div class="p1">hello world hello world hello world hello world hello world</div>
<div class="p2">hello world hello world hello world hello world hello world</div>
<div class="p3">hello world hello world hello world hello world hello world</div>
<div class="p4">hello world hello world hello world hello world hello world</div>
<div class="p5">hello world hello world hello world hello world hello world</div>
</body>
</html>
Be sure to specify the width of the container when using the above attributes
边栏推荐
猜你喜欢

(2022杭电多校三)1011-Link is as bear(思维+线性基)

Deep understanding of Base64 underlying principles

Cloudera manager platform fault repair record

Microcomputer principle and interface technology

NXP i.mx8mp-deepviewrt

最新二开版漫画小说听书三合一完整源码/整合免签接口/搭建教程/带采集接口

Matlab learning -- structured programs and user-defined functions

容斥原理

Rdkit II: use rdkit screening to screen 2D pharmacophores of chemical small molecules

深入C语言(3)—— C的输入输出流
随机推荐
Getting started with caspin
Spark dataframe replaces empty characters (or other values) in each column with null
Excel拼接数据库语句
Anaconda offline installation environment
Cannot paste multiple pictures at once
Build redis environment under windows and Linux
Excel splicing database statement
sql
Naive Bayes -- continuous data
2. 变量及作用域
Numpy acceleration -- > cupy installation
Arm architecture and neural network
Code ~ hide or disable the status bar and virtual keys
Tonight at 7:30 | is the AI world in the eyes of Lianjie, Jiangmen, Baidu and country garden venture capital continue to be advanced or return to the essence of business
Why do programmers so "dislike" the trunk development mode?
Install the packet capturing certificate
How do programmers use code to completely end those things in the system?
Microcomputer principle and interface technology
Beijing post network research 2015 problem2
Android view system and custom view Series 1: (kotlin version)