Two methods of using CSS style to intercept the length of the title do not need to use functions

For example, when we make the website template, or choose to download to a good default, maybe due to the details, the title of the article called by the sidebar or article list is too long. We need to intercept by means. In the article “function for automatically intercepting the number of characters in zblog PHP summary”, I need to achieve the interception of zblog PHP content. I use the substrutf8 function.

But not all CMS have built-in functions. If not, we need to add them. The simplest way is to use CSS style to intercept the length of the title.

First, the title style for span or Li

.text-css {
display:block;/ *Add * / < br > to inline objectswidth:31em;
word- break:keep-all;/ *Do not wrap * / < br > linewhite- space:nowrap;/ *Do not wrap * / < br > lineoverflow:hidden;/ *Hide the content beyond the width * / < br > when the content exceeds the widthtext- overflow:ellipsis;/ *When the text in the object overflows, the ellipsis mark (…) is displayed overflow:hidden; Used together. */
}

We only need to apply the. Text CSS style to Li or span. we can modify the above style and intercept the length as needed.

Second, table interception style

table{
width:30em;
table- layout:fixed; }/*Only if the table layout algorithm is defined as fixed, the following definition of TD can work. */

td{
width:100%;
word- break:keep-all;/ *Do not wrap * / < br > linewhite- space:nowrap;/ *Do not wrap * / < br > lineoverflow:hidden;/ *Hide the content beyond the width * / < br > when the content exceeds the widthtext- overflow:ellipsis; }/*When the text in the object overflows, the ellipsis mark (…) is displayed overflow:hidden; Used together. */

The above is for the table when intercepting, generally we use less.

Related Article
Method to solve the disorder of Chinese content in MySQL database submitted by PHP

Whether it is ASP or PHP programming language, or even other web languages, the basic application is nothing more than Read more

Two regular expression verification methods for PHP user registered mailbox

Generally, when we register or log in to an account on the web, we need to verify not only whether Read more

Three common methods of PHP connecting MySQL database

For PHP entry-level users, we only need to master the basic database write, read, edit, delete and other basic operations. Read more

Solve the problem of Chinese garbled in VIM edit file under Linux system

If we need to edit the files in the Linux system, we may download them locally, open them with an Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image