Home Web Front-end HTML Tutorial How to use ellipsis when the number of characters displayed in html text control exceeds the limit

How to use ellipsis when the number of characters displayed in html text control exceeds the limit

May 18, 2018 pm 05:02 PM

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 "...". 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 ellipsis is added

How to use ellipsis when the number of characters displayed in html text control exceeds the limit

First of all, let me explain that DIV is generally used The text in the +css container that exceeds the length will float outside the frame or expand the frame. This is generally easy to solve, but I encountered this problem today: the test page did not respond under IE6, but the test page processed normally under IE8 I was depressed when I saw overflow text. 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 It’s normal if you hit it, sweat! ! ! The following is a screenshot of my processing:
    The following is the code of the html page:

    How to use ellipsis when the number of characters displayed in html text control exceeds the limit

    The following is the rendering (it will be the same after processing):

    How to use ellipsis when the number of characters displayed in html text control exceeds the limit

    The following is the code for the above two overflow processing:

    How to use ellipsis when the number of characters displayed in html text control exceeds the limit

    The following are some processing methods on the Internet, which are worth your reference:

    General text truncation (applicable to inline and block):
    [www.mb5u.com]

    .text-overflow {
    display:block;
    width:31em;
    word-break:keep-all;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    }
    Copy after login

    For the definition of table text overflow:
    ww.m5u.com]

    table{
    width:30em;
    table-layout:fixed;
    }
    td{
    width:100%;
    word-break:keep-all;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    }
    Copy after login

    What you need to pay attention to is that this stuff only works on a single line of text. If you want to use it on multiple lines, only the first line will work. Only IE will have "..." in this way of writing, and other browsers will hide it when the text exceeds the specified width.

    In-depth study of Chinese text overflow processing in opera and Firefox:
    [Problem]
    Recently I discovered that when browsing under opera, the right half of my space becomes oversized. wide (I use the same typesetting mode as you), so that it exceeds the display range of 1024 and a horizontal scroll bar appears when the window is maximized. After deleting all modules according to the method you provided, the problem is still there Like this. I am puzzled...
    I opened a new space with another pass, using the same layout, but there is no problem under Opera!
    Is it because I tested the expanded space during the test? The space on the right, as well as adding a second html module [and then deleting it] and other operations, caused my space code to be messed up?

    [Reason]

    Compatibility issue with different browsers, to be precise, it is an issue with implementation of CSS standards by different browsers. First of all, you should know that it is not just Opera that displays abnormally, Firefox No. Since Firefox is a recognized standard browser [of course, so is Opera] and has a higher market share, Firefox is used for certification.

    [Example]

    1. Firefox does not Supports the ellipsis (...) attribute, that is, a long string will display an ellipsis. text-overflow: ellipsis;
    This can be found in the log options on the space log editing page There is an application. If you enter a very long category name and come back to edit the log, you will find that the original category name will display the first part in IE, and then directly replace it with an ellipsis. However, in browsers such as Firefox, it will display very long until it bursts. Interface framework.

    2. In Firefox, style="overflow:hidden"only works on

    instead of or

    , etc.
    3. In the fixed link part, IE browser can use the word-wrap attribute to wrap the string that exceeds the width. Specifically, once the address length of the fixed link exceeds 300px, it will automatically wrap. .bvwordwrap{word-wrap:break-word;width:300px;left:0}
    AndIn browsers such as Firefox, the word-wrap attribute is not recognized because This CSS property does not comply with the W3 standard and should be replaced by white-space:normal; so that the line breaks can be correct under FireFox and IE. Also note that spaces between words cannot be used  to replace it, otherwise it will not be able to wrap correctly.

    [Related recommendations]

    1. css solves the problem that the number of text words exceeds the display Methods of ellipsis... (single line, multi-line text)

    2. Use css to solve the problem of exceeding the number of characters in the title display

    3. Online html Free video tutorial

  • The above is the detailed content of How to use ellipsis when the number of characters displayed in html text control exceeds the limit. 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)

    Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

    Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

    Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

    This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

    HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

    Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

    HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

    Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

    HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

    Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

    HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

    Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

    Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

    Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

    HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

    Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

    See all articles