Home Web Front-end HTML Tutorial Example tutorial on limiting the display length of characters and adding ellipses

Example tutorial on limiting the display length of characters and adding ellipses

Jun 11, 2017 pm 01:30 PM

How to solve the problem that the number of words displayed in html text control exceeds the limit? That is, the text overflow control displays the number of words, and the table text overflow control td displays the number of words. When you see the title, you will easily think of the method of truncating the text and adding an ellipsis "...". Haha, that's it. In fact, writing this log is just to record this method, because it seems that many people still don’t remember how to deal with such a situation. The picture below is the display effect of php Chinese website (www.php.cn) when the number of words exceeds the number and ellipses are added. First, let me explain. Generally, if the text in a container using DIV+css exceeds the length, it will float outside the frame or expand the frame. This is generally It's easy to solve, but I encountered this problem today: the test page under IE6 did not respond, but the test page under IE8 processed the overflow text normally, and I was depressed. Isn't this overflow processing unique to IE? Why is IE6 not working properly? Later, I checked online and found out that it turns out that IE6 only supports overflow processing if it is written inside a DIV, and IE6 or above only supports writing it in

  • , so I wrote the same overflow processing code in DIV and < li> It’s normal

    1. HTML text control display word count exceeds the method of using ellipses

    Example tutorial on limiting the display length of characters and adding ellipses

    Introduction: How to solve the problem that the number of words displayed in HTML text control exceeds the limit? That is, text overflow controls the number of words displayed, and table text overflow controls the number of words displayed in td. When you see the title, you will easily think of the method of truncating the text and adding an ellipsis "...".

    2. Use css3 to truncate text and add ellipses

    Example tutorial on limiting the display length of characters and adding ellipses

    Introduction: Limit the number of lines of text displayed in a block element. In order to achieve this effect, it needs to be combined with other foreign WebKit properties.

    3. Example of adding ellipsis code after the intercepted string implemented in pure css_html/css_WEB-ITnose

    Introduction: Example of adding ellipsis code after the intercepted string implemented in pure CSS

    4. How does php limit the display length of characters?

    Introduction: Like the above (interception from Tieba), when the character length exceeds the fixed pixel width, the string within the pixel width range is intercepted, and after the string Add an ellipsis. The mb_strlen function can only get the number of characters, but the width of a character in English and Chinese is different, and it cannot be determined based on the number of characters...

    5. php String interception problem

    #Introduction: I want to display a string with a limited length. If the string exceeds a certain length, intercept the first n characters and add an ellipsis after it.

    6. php string interception problem_php skills

    Introduction: I want to limit the length of a string Display, if the string exceeds a certain length, intercept the first n characters and add an ellipsis

    [Related Q&A recommendations]:

    javascript - Is there any good way to add ellipses at the end of lines when multi-line text overflows?

    javascript - How to add ellipses to the overflow part of multi-line text?

    How to limit the display length of characters in php?

    javascript - Display multiple lines, hide beyond that, and add an ellipsis at the end of the last line?

    The above is the detailed content of Example tutorial on limiting the display length of characters and adding ellipses. For more information, please follow other related articles on the PHP Chinese website!

  • Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

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

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

    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.

    What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

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

    The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

    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.

    What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

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

    What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

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

    Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

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

    What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

    AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

    Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

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

    See all articles