CSS, j's single-line, multi-line text overflow displays ellipsis
In the project, due to too much actual description text, the vertical length of the initial page is too long, which also reduces the utilization of the remaining information; therefore, when there is too much text, it is necessary to initialize the number of lines.
1. CSS single line text overflows and ellipses are displayed
<span style="color: #0000ff;"><</span><span style="color: #800000;">div </span><span style="color: #ff0000;">style</span><span style="color: #0000ff;">="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"</span><span style="color: #0000ff;">></span><span style="color: #000000;"> 我要溢出,我要溢出,我要溢出,我要溢出,我要溢出,我要溢出,我要溢出,我要溢出,我要溢出,我要溢出,我要溢出,我要溢出。 </span><span style="color: #0000ff;"></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
2. CSS multi-line text overflows and displays ellipses
<span style="color: #0000ff;"><</span><span style="color: #800000;">div </span><span style="color: #ff0000;">style</span><span style="color: #0000ff;">="overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;"</span><span style="color: #0000ff;">></span><span style="color: #000000;"> 我要溢出,多行文本,我要溢出,多行文本,我要溢出,多行文本,我要溢出,多行文本,我要溢出,多行文本,我要溢出,多行文本,我要溢出,多行文本,我要溢出,多行文本,我要溢出,多行文本,我要溢出,多行文本,我要溢出,多行文本,我要溢出,多行文本。 </span><span style="color: #0000ff;"></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
The above two are suitable for situations where there is only text in the label, and sometimes we will encounter such a situation
<span style="color: #0000ff;"><</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span>我是内容<span style="color: #0000ff;"></</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span>我是内容<span style="color: #0000ff;"></</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span>我是内容<span style="color: #0000ff;"></</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span>我是内容<span style="color: #0000ff;"></</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
3. The third way is to solve the problems encountered in the above situation
I have seen many examples on the Internet, and each has its own advantages. The one I use is a fixed line-height. The line breaks are also at a fixed height for each line, such as: line-height:20px;, and a blank line is added each time. Also let the blank line be 20px, so that we can use multiples of 20 to reasonably display the number of lines and content to be displayed
<span style="color: #0000ff;"><</span><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="text"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span><span style="color: #000000;"> 你不想要改变世界,但是你想要看日出?想要体验下传说中的晨跑?想在晨跑中偶遇男神女神?想要看下早上5点图书馆或训练场是否有人?想呼吸下还没被汽车尾气过度渲染的空气?想给自己给爱人做个早餐?你得早起呀!昨晚事情没做完?考研单词还差几页?赶飞机、赶火车?你得早起呀!你不想上班也得早起请假不是嘛~ </span><span style="color: #0000ff;"></</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span><span style="color: #000000;"> 欢迎大家参加早起的鸟儿有虫吃-21天早起计划。一日之计在于晨,在沐浴晨光的过程中,我们祝愿大家开始美好的一天! </span><span style="color: #0000ff;"></</span><span style="color: #800000;">p</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><</span><span style="color: #800000;">span </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="points"</span><span style="color: #0000ff;">></span>...<span style="color: #0000ff;"></</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #800000;">.text</span>{<span style="color: #ff0000;">color</span>:<span style="color: #0000ff;">#707070</span>;<span style="color: #ff0000;">padding</span>:<span style="color: #0000ff;">0 12px</span>;<span style="color: #ff0000;">position</span>:<span style="color: #0000ff;">relative</span>;<span style="color: #ff0000;">line-height</span>:<span style="color: #0000ff;">20px</span>;<span style="color: #ff0000;">overflow</span>:<span style="color: #0000ff;">hidden</span>;<span style="color: #ff0000;"> margin-bottom</span>:<span style="color: #0000ff;">12px</span>;<span style="color: #ff0000;">max-height</span>:<span style="color: #0000ff;">60px</span>;}<span style="color: #800000;"> .points</span>{<span style="color: #ff0000;">content</span>:<span style="color: #0000ff;">"..."</span>;<span style="color: #ff0000;">position</span>:<span style="color: #0000ff;">absolute</span>;<span style="color: #ff0000;">bottom</span>:<span style="color: #0000ff;">0</span>;<span style="color: #ff0000;">right</span>:<span style="color: #0000ff;">16px</span>;<span style="color: #ff0000;">padding-left</span>:<span style="color: #0000ff;">40px</span>;<span style="color: #ff0000;">font-size</span>:<span style="color: #0000ff;">18px</span>;<span style="color: #ff0000;">letter-spacing</span>:<span style="color: #0000ff;">3px</span>;<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;"> -webkit-linear-gradient(left, transparent, #fff 55%)</span>;<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;"> -o-linear-gradient(right, transparent, #fff 55%)</span>;<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;"> -moz-linear-gradient(right, transparent, #fff 55%)</span>;<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;"> linear-gradient(to right, transparent, #fff 55%)</span>;}<span style="color: #800000;"> .text p</span>{<span style="color: #ff0000;">margin</span>:<span style="color: #0000ff;">0</span>;}<span style="color: #800000;"> .text p+p</span>{<span style="color: #ff0000;">margin-top</span>:<span style="color: #0000ff;">20px</span>;}
<span style="color: #008000;">//</span><span style="color: #008000;"> 字体显示</span> <span style="color: #0000ff;">var</span> showBoo = <span style="color: #0000ff;">true</span><span style="color: #000000;">; $(</span>'.de-box .text').on('click',<span style="color: #0000ff;">function</span><span style="color: #000000;">(){ </span><span style="color: #0000ff;">if</span><span style="color: #000000;">(showBoo){ console.log(</span>1<span style="color: #000000;">); $(</span>'.de-box .text').css('maxHeight','none'<span style="color: #000000;">); $(</span>'.de-box .points'<span style="color: #000000;">).hide(); showBoo </span>= <span style="color: #0000ff;">false</span><span style="color: #000000;">; }</span><span style="color: #0000ff;">else</span><span style="color: #000000;">{ $(</span>'.de-box .text').css('maxHeight','60px'<span style="color: #000000;">); $(</span>'.de-box .points'<span style="color: #000000;">).show(); showBoo </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">; }; });</span>
In this case, line breaks will appear and blank lines will be displayed. I will leave this problem for now. I am a little tired today

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...
