


Regarding the ellipses that appear when CSS multi-line text overflows
This article mainly introduces relevant information on examples of ellipses appearing when CSS multi-line text overflows. The content is quite good. I will share it with you now and give it as a reference.
Ellipses appear when multi-line text overflows
This article recommends 2 methods.
1. css
tip: Only compatible with browsers with chrome kernel. ff is not supported.
.box { overflow: hidden; /* 溢出时不显示溢出的内容 */ text-overflow: ellipsis; /* 发生溢出时使用省略号代替 */ display: -webkit-box; /* chrome浏览器的私有属性。显示为box。 */ -webkit-box-orient: vertical; /* 垂直排列元素 */ -webkit-line-clamp: 2; /* 显示多少行 */ }
Extension
word-wrap
Keyword | Description | Default value | Value |
---|---|---|---|
Specifies the conditions for word wrapping | normal, line breaks at word hyphenation points. | break-word, break a line within a word. | |
Description | Default value | Value | |
---|---|---|---|
How to display text beyond the box | clip, Trim text. ellipsis, displays the ellipsis. string, displays the specified text. |
Description | Default value | Value | |
---|---|---|---|
How to treat blanks and whether to wrap lines | normal, blank will be ignored by the browser. | pre, leave blank. nowrap, the text does not wrap. pre-wrap, keep blanks and wrap normally. pre-line, merge whitespace, retain newlines. |
This attribute is not supported by browsers yet. You need to use the private properties of the respective browsers.
Description | Default value | Value | |
---|---|---|---|
How to order child elements | inline-axis, child elements are along the inline coordinate axis (mapped to the horizontal direction). | horizontal, specifies that child elements are arranged from left to right on a horizontal line. vertical, arranges child elements vertically from top to bottom. block-axis, child elements are along the block axis (mapped to vertical). inherit, inherit the parent element. |
Only browsers with chrome core support their own private properties.
How many rows of block-level elements are displayed.
2. jsThere are many ways to use js to control how overflow text is displayed. Here is a recommended script file: ellipsis.js
ellipsis.js
ellipsis | |
ellipsis git | |
1. Introduce the script file
<script src="https://cdn.jsdelivr.net/npm/ellipsis.js@0.1.3/ellipsis.js"></script>
var ell = Ellipsis({ lines: 3 }) var ele = document.getElementsByClassName('test') ell.add(ele)
Extension
It also has some configuration items. If not configured, the default value is used.
{ ellipsis: '...', // 默认显示的替代文本 debounce: 0, // 延迟多长时间后执行 responsive: true, // 是否有窗口大小改变时执行 className: '.clamp', // 默认操作具有这个类的元素。 lines: 2, // 默认只出现2行元素。 portrait: null, // 默认不改变,如果你想要在竖屏模式下有不同的行数, break_word: true // 默认截断单词。 }
About the use of the greater than sign in CSS styles and the inheritance method in Css
The above is the detailed content of Regarding the ellipses that appear when CSS multi-line text overflows. For more information, please follow other related articles on the PHP Chinese website!

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

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

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.

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

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-
