


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
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
The following is the code of the html page:
The following is the rendering (it will be the same after processing):
The following is the code for the above two overflow processing:
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; }
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; }
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
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]
2. Use css to solve the problem of exceeding the number of characters in the title display
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!

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.


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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
