Ellipses appear when multi-line text overflows This article recommends 2 methods. 1. CSS Tip: Only compatible with Chrome browsers. ff is not supported. .box { overflow: hidden; /* Overflow content is not displayed when overflow occurs*/ text-overflow: ellipsis; /* Use ellipsis instead when overflow occurs*/ display: -webkit-box; /* Private properties of the Chrome browser. Displayed as a box. */ -webkit-box-orient: vertical; /* Arrange elements vertically */ -webkit-line-clamp: 2; /* How many lines to display */ } Extension word-wrap
text-overflow
white-space
box-orient This property is not yet supported by browsers. Need to use the private properties of each browser.
line-clamp Only Chrome-based browsers support their own private properties. How many lines of block-level elements to display. 2.js There are many ways to use js to control how overflow text is displayed. Here is a recommended script file: ellipsis.js ellipsis.js
Directions: 1. Import script files <script src="https://cdn.jsdelivr.net/npm/[email protected]/ellipsis.js"></script> 2. Use 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: '...', // The default alternative text to display debounce: 0, // The delay before executing responsive: true, // Whether to execute when the window size changes className: '.clamp', // The default action is for elements with this class. lines: 2, // Only 2 lines of elements appear by default. portrait: null, // No change by default, if you want a different number of rows in portrait mode, break_word: true // Break words by default. } 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. |
<<: Vue implements real-time refresh of the time display in the upper right corner
>>: HTML Tutorial: Collection of commonly used HTML tags (6)
Preface In daily development, when we use MySQL t...
Sysbench is an excellent benchmark tool that can ...
Table of contents Preface 1. Nginx installation 1...
1. Command Introduction The usermod (user modify)...
Floating elements cause their parent elements to ...
Table of contents App Update Process Rough flow c...
This article mainly introduces the wonderful use ...
Preface Golang provides the database/sql package ...
CSS sets Overflow to hide the scroll bar while al...
Table of contents 1. Error message 2. Cause of er...
Table of contents 1. Where is the slowness? 2. Ha...
1. Create a test table CREATE TABLE `mysql_genara...
This article example shares the specific code of ...
First of all, you can understand the difference b...
There are 4 commonly used methods, as follows: 1....