A text display method, device, equipment and storage medium
By creating sub-nodes of block-level elements in the Web front-end page and using positioning attributes to add a third sub-node, the effect of omitting text in the middle is achieved, which solves the problems of text display performance loss and low recognition in the existing technology, and improves user experience. experience.
Patent Information
- Application Number
- CN202210706557.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-21
- Publication Date
- 2024-09-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the existing technology, when long text that exceeds the width of the parent container is displayed in a Web front-end web page, a JS script is required to display an ellipsis in the middle, resulting in performance loss, and the ellipsis displayed at the end cannot distinguish similar text, affecting the user experience.
By creating child nodes of block-level elements in the Web front-end page, and using the positioning attribute to add a third child node to the second half of the exceeded area, set its text display mode to back to front, display ellipses, and achieve the effect of omitting the middle of the text. , improve recognition and user experience.
Only the cascading style sheet attributes are used to achieve the omission effect in the middle of the text, which improves the recognition and user experience of text display and makes the text display more humane.
Smart Images

Figure CN114896538B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a text display method, device, equipment and storage medium. Background Art
[0002] Currently, when long text that exceeds the width of the parent container is displayed on a Web (World Wide Web) front-end (including PC and H5 mobile) web page type page, an ellipsis is usually displayed at the end or in the middle of the text.
[0003] However, on the one hand, the method of displaying ellipsis in the middle of text mostly requires the use of JS (JavaScript, a lightweight programming language) scripting language to participate in the calculation, and JS will block the loading and rendering of the page when loading, and it needs to occupy computer resources when calculating, which has a certain loss on the performance of the program. On the other hand, although the method of displaying ellipsis at the end of the text only uses CSS (Cascading Style Sheets), this method has a disadvantage, that is, when the contents of two or more paragraphs of text are very similar, especially when the front-end content is the same and only the end content, such as several dates and serial number timestamps, is different, displaying ellipsis at the end of the text will not be able to intuitively see the difference between the two texts, which will seriously affect the user's perceptual experience.
[0004] Therefore, in view of the above problems and defects, how to optimize the display of long text that exceeds the width of the parent container is a problem that needs to be further solved. Summary of the invention
[0005] In view of this, the purpose of this application is to provide a text display method, device, equipment and storage medium, which can use the existing attributes of cascading style sheets to achieve the effect of ellipsis in the middle of text, improve the recognition of text display, and enhance the user experience, making the text display more humane. The specific scheme is as follows:
[0006] In a first aspect, the present application discloses a text display method, comprising:
[0007] Determine the target display area for displaying the target text in the Web front-end page;
[0008] Creating a first subnode and a second subnode for displaying the target text in the target display area, and setting the elements in the first subnode and the second subnode as block-level elements;
[0009] Determine whether the width of the target text exceeds the width of the target display area;
[0010] If the width of the target text exceeds the width of the target display area, a third subnode is added to the second half of the display area of the second subnode using the positioning attribute, and the text display mode in the third subnode is set to be from back to front. At the same time, the text exceeding the display area of the third subnode is set to ellipsis, and finally the target text is displayed in the second subnode and the third subnode.
[0011] Optionally, before creating the first subnode and the second subnode for displaying the target text in the target display area, the method further includes:
[0012] The line height of the target display area is set to be the same as the height of the target text by using a cascading style sheet, and the text exceeding the target display area is set to be invisible.
[0013] Optionally, creating a first sub-node and a second sub-node for displaying the target text in the target display area includes:
[0014] Creating a first sub-node and a second sub-node for displaying the target text in the target display area;
[0015] The second subnode is moved below the first subnode; wherein the first subnode is adjacent to the second subnode.
[0016] Optionally, after setting the elements in the first child node and the second child node as block-level elements, the method further includes:
[0017] Setting the maximum height of the first child node to twice the height of the target display area;
[0018] The second child node is moved upward by a distance twice the height of the target display area.
[0019] Optionally, if the width of the target text exceeds the width of the target display area, adding a third sub-node in the rear half of the display area of the second sub-node by using a positioning attribute includes:
[0020] If the width of the target text exceeds the width of the target display area, a title attribute is added to the second child node, and a third child node is added to the rear half of the display area of the second child node using a positioning attribute.
[0021] Optionally, after displaying the target text in the second subnode and the third subnode, the method further includes:
[0022] When it is detected that the mouse moves into the target display area, the complete content of the target text is displayed in the tooltip text.
[0023] Optionally, displaying the target text in the second subnode and the third subnode includes:
[0024] The target text is displayed in the second sub-node and the third sub-node in the order of selecting a field of the first preset width from the beginning, an ellipsis, and selecting a field of the second preset width from the end; wherein the sum of the first preset width, the second preset width and the width of the ellipsis is equal to the width of the target display area.
[0025] In a second aspect, the present application discloses a text display device, comprising:
[0026] A display area determination module is used to determine a target display area for displaying target text in a Web front-end page;
[0027] A subnode creation module, used to create a first subnode and a second subnode for displaying the target text in the target display area, and set the elements in the first subnode and the second subnode as block-level elements;
[0028] A judging module, used to judge whether the width of the target text exceeds the width of the target display area;
[0029] A sub-node adding module, used for adding a third sub-node to the rear half of the display area of the second sub-node by using a positioning attribute if the width of the target text exceeds the width of the target display area;
[0030] A setting module, used to set the display mode of the text in the third sub-node to be from back to front, and set the text beyond the display area of the third sub-node to be ellipsis;
[0031] A display module is used to display the target text in the second sub-node and the third sub-node.
[0032] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein the processor implements the aforementioned text display method when executing a computer program stored in the memory.
[0033] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned text display method is implemented.
[0034] It can be seen that the present application first determines the target display area for displaying the target text in the Web front-end page, then creates the first sub-node and the second sub-node for displaying the target text in the target display area, and sets the elements in the first sub-node and the second sub-node as block-level elements, and then determines whether the width of the target text exceeds the width of the target display area. If the width of the target text exceeds the width of the target display area, a third sub-node is added to the back half of the display area of the second sub-node using the positioning attribute, and the text display mode in the third sub-node is set to be from back to front, and the text that exceeds the display area of the third sub-node is set to an ellipsis, and finally the target text is displayed in the second sub-node and the third sub-node. The present application can achieve the effect of omitting the text in the middle by only using the existing attributes of the cascading style sheet, which improves the recognition of the text display, enhances the user experience, and makes the text display more user-friendly. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0036] Figure 1 A flow chart of a text display method disclosed in this application;
[0037] Figure 2 Creating a schematic diagram for a specific subnode disclosed in this application;
[0038] Figure 3 A specific sub-node text display schematic diagram disclosed in this application;
[0039] Figure 4 A schematic diagram of a specific sub-node setting disclosed in this application;
[0040] Figure 5 A schematic diagram of a specific sub-node setting disclosed in this application;
[0041] Figure 6 A specific schematic diagram of sub-node position movement disclosed in this application;
[0042] Figure 7 Creating a schematic diagram for a specific subnode disclosed in this application;
[0043] Figure 8 A specific sub-node text display schematic diagram disclosed in this application;
[0044] Fig. 9 A specific sub-node text display schematic diagram disclosed in this application;
[0045] Fig.10 This is a structural schematic diagram of a text display device disclosed in this application;
[0046] Fig.11 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] The present application embodiment discloses a text display method, see Figure 1 As shown, the method includes:
[0049] Step S11: determining a target display area in a Web front-end page for displaying a target text.
[0050] In this embodiment, it is first necessary to determine a target display area in the Web front-end page for displaying a target text, wherein the content of the target text includes but is not limited to information such as text symbols, numeric symbols, English symbols, and punctuation marks.
[0051] Step S12: creating a first subnode and a second subnode for displaying the target text in the target display area, and setting the elements in the first subnode and the second subnode as block-level elements.
[0052] In this embodiment, after determining the target display area for displaying the target text in the Web front-end page, two subnodes for displaying the target text can be created in the target display area to obtain a first subnode and a second subnode, and then the elements in the first subnode and the second subnode are set as block-level elements. Figure 2 As shown, after the target display area is determined, two child nodes are defined, both for displaying the target text "a text display method device", which are node A and node B respectively.
[0053] It should be pointed out that before creating the first subnode and the second subnode for displaying the target text in the target display area, it specifically also includes: using a cascading style sheet to set the line height of the target display area to the same height as the target text, and setting the text that exceeds the target display area to be invisible. In a specific implementation, the height of the display area is set to 1 times the line height, that is, the height of a line of text to be displayed, through a cascading style sheet (CSS). For example, when the height of the text to be displayed is 1.5em (emphasize, a relative length unit), the line height line-height of the display area is set to 1.5em, and the text portion that exceeds the display area is set to be invisible. This can be specifically set through the attribute overflow:hidden. After completing the above settings, when displaying the text to be displayed, refer to Figure 3 As shown, for a text whose content is "A text display method device", when the width of the display area, that is, the width of the parent container, does not exceed the width of the text, "A text display method device" will be displayed in the display area; when the width of the display area exceeds the width of the text, that is, the display area cannot fully display the text in one line, the portion of the text that exceeds the target display area will be outside the display area and will not be visible to the user.
[0054] In this embodiment, the step of creating a first subnode and a second subnode for displaying the target text in the target display area may specifically include: creating a first subnode and a second subnode for displaying the target text in the target display area; moving the second subnode to the bottom of the first subnode; wherein the first subnode is adjacent to the second subnode. Figure 4 As shown, Figure 3 Node B defined in is moved to the bottom of node A in the display area, and node A is made adjacent to node B. At this time, since node B is outside the display area, the content of node B is not visible, and only the content of node A can be seen.
[0055] In this embodiment, after setting the elements in the first subnode and the second subnode as block-level elements, the method further includes: setting the maximum height of the first subnode to twice the height of the target display area; and moving the second subnode upward by a distance twice the height of the target display area. Figure 5 and Figure 6As shown, the maximum height of node A is first set to twice the line height, that is, twice the height of the display area. At this time, when the width of the display area is sufficient, the height occupied by node A is one line height. When the width of the display area is not enough, the content of node A that exceeds the width of the display area will automatically wrap, and the total height is twice the line height. Further, node B is moved upward by a distance of twice the line height relative to its own position, that is, moved to the top adjacent to node A. At this time, when the width of the display area is sufficient, the height of node A is one line height, and node B is located above node A. Since it is located outside the display area, the text content in node B is not visible; when the width of the display area is not enough, the height of node A is twice the line height, and node B is just within the display area, and since the level of the positioning attribute in the cascading style sheet is higher than that of node A, node B will cover the content of node A. It should be pointed out that the maximum height setting of the first child node can be set according to the actual application requirements, and can be a preset multiple of the height of the target display area, and no specific limitation is made here.
[0056] Step S13: Determine whether the width of the target text exceeds the width of the target display area.
[0057] In this embodiment, after setting the elements in the first child node and the second child node as block-level elements, it is determined whether the width of the above-mentioned target text exceeds the width of the above-mentioned target display area, that is, it is determined whether the current target text to be displayed exceeds the total text content that can be displayed by the parent container. If it does not exceed, the above-mentioned target text can be directly displayed in the above-mentioned target display area.
[0058] Step S14: If the width of the target text exceeds the width of the target display area, a third subnode is added to the rear half of the display area of the second subnode using the positioning attribute, and the text display mode in the third subnode is set to be from back to front. At the same time, the text exceeding the display area of the third subnode is set to ellipsis, and finally the target text is displayed in the second subnode and the third subnode.
[0059] In this embodiment, if the width of the target text exceeds the width of the target display area, a third subnode can be added in the second half of the display area of the second subnode, that is, the right half of the target display area, using the positioning attribute, and then the text display mode in the third subnode is set to be from back to front, that is, the content displayed in the third subnode is the content obtained by cutting the preset length from the end of the target text to the beginning. At the same time, the text exceeding the display area of the third subnode is set to an ellipsis, and finally the target text is displayed in the second subnode and the third subnode. It should be pointed out that when displaying the target text, in addition to displaying it in the target display area in a display order from left to right, other display orders are also included, such as displaying it in a display order from right to left.
[0060] In a specific implementation, the displaying of the target text in the second subnode and the third subnode may specifically include: displaying the target text in the second subnode and the third subnode in the order of selecting a field of a first preset width from the beginning, an ellipsis, and selecting a field of a second preset width from the end; wherein the sum of the first preset width, the second preset width, and the width of the ellipsis is equal to the width of the target display area. For example, see Figure 7 , Figure 8 and Fig. 9 As shown, if the width of the target text "a text display method device" exceeds the width of the display area, a new node C is added, and the width of node C is set to half of the display area. At this time, the positioning attribute can be used to display node C in the second half of the display area, that is, the right half of node B, and the content of node C is set to be the same as the content of the display area, that is, like nodes A and B, it is displayed in the order of the target text from front to back. Further, the text display of node C is modified to be from back to front, that is, from right to left, and the text content exceeding the node is set to be displayed as ellipsis. Since the text is displayed from right to left at this time, the ellipsis will be displayed on the leftmost side of node C. The final text display effect is as follows: Fig. 9 As shown in the figure, it is a "text ... method device", that is, according to the target text, a field of a first preset width is selected from the beginning to the end, an ellipsis, and a field of a second preset width is selected from the end to the end to be displayed in nodes B and C. It can be understood that the sum of the width of the first preset width, the second preset width and the ellipsis is equal to the total width of the target display area.
[0061] Furthermore, in order to improve the user experience and enable the user to better obtain the hidden text display content, if the width of the target text exceeds the width of the target display area, a third subnode is added in the second half of the display area of the second subnode using the positioning attribute. Specifically, it may include: if the width of the target text exceeds the width of the target display area, a title attribute is added to the second subnode, and a third subnode is added in the second half of the display area of the second subnode using the positioning attribute. For example, when the width of the target text exceeds the width of the target display area, a title attribute is added to the above-mentioned node B, and then a node C is added in the second half of the display area of node B.
[0062] In the present embodiment, after the target text is displayed in the second sub-node and the third sub-node, the method further includes: when the mouse is detected to move into the target display area, the complete content of the target text is displayed in the tool tip text. That is, when the text content cannot be fully displayed in the display area, an ellipsis appears in the middle, and the full content will be displayed when the mouse is placed on it. It is understandable that, since the title attribute is added to the above-mentioned node B, the content set by the title attribute will be displayed in the tool tip text when the mouse is detected to move into the above-mentioned node B, that is, the more detailed full content in the target text will be displayed. Since the title attribute is not set for node A, it will not be prompted when it is moved in.
[0063] It can be seen that the embodiment of the present application first determines the target display area for displaying the target text in the Web front-end page, and then creates the first subnode and the second subnode for displaying the target text in the target display area, and sets the elements in the first subnode and the second subnode to block-level elements, and then determines whether the width of the target text exceeds the width of the target display area. If the width of the target text exceeds the width of the target display area, a third subnode is added to the back half of the display area of the second subnode using the positioning attribute, and the text display mode in the third subnode is set to be from back to front, and the text that exceeds the display area of the third subnode is set to an ellipsis, and finally the target text is displayed in the second subnode and the third subnode. The embodiment of the present application can achieve the effect of omitting the text in the middle by only using the existing attributes of the cascading style sheet, which improves the recognition of the text display, enhances the user experience, and makes the text display more humane.
[0064] Correspondingly, the present application also discloses a text display device, see Fig.10 As shown, the device comprises:
[0065] A display area determination module 11 is used to determine a target display area in a Web front-end page for displaying a target text;
[0066] A subnode creation module 12, configured to create a first subnode and a second subnode for displaying the target text in the target display area, and set the elements in the first subnode and the second subnode as block-level elements;
[0067] A judging module 13 is used to judge whether the width of the target text exceeds the width of the target display area;
[0068] A sub-node adding module 14 is used for adding a third sub-node to the rear half of the display area of the second sub-node by using a positioning attribute if the width of the target text exceeds the width of the target display area;
[0069] A setting module 15, used to set the display mode of the text in the third sub-node to be from back to front, and set the text beyond the display area of the third sub-node to be ellipsis;
[0070] The display module 16 is used to display the target text in the second sub-node and the third sub-node.
[0071] Among them, the specific working processes of the above-mentioned modules can refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0072] It can be seen that in the embodiment of the present application, the target display area for displaying the target text in the Web front-end page is first determined, and then the first sub-node and the second sub-node for displaying the target text are created in the target display area, and the elements in the first sub-node and the second sub-node are set as block-level elements, and then it is determined whether the width of the target text exceeds the width of the target display area. If the width of the target text exceeds the width of the target display area, a third sub-node is added to the back half of the display area of the second sub-node using the positioning attribute, and the text display mode in the third sub-node is set to be from back to front, and the text that exceeds the display area of the third sub-node is set to an ellipsis, and finally the target text is displayed in the second sub-node and the third sub-node. The embodiment of the present application can achieve the effect of omitting the text in the middle by only using the existing attributes of the cascading style sheet, which improves the recognition of the text display, enhances the user experience, and makes the text display more humane.
[0073] In some specific embodiments, before the sub-node creation module 12, the following steps may also be included:
[0074] The first setting unit is used to set the line height of the target display area to be the same as the height of the target text by using a cascading style sheet, and to set the text exceeding the target display area to be invisible.
[0075] In some specific embodiments, the subnode creation module 12 may specifically include:
[0076] A subnode creation unit, configured to create a first subnode and a second subnode in the target display area for displaying the target text;
[0077] The first subnode moving unit is used to move the second subnode to below the first subnode; wherein the first subnode is adjacent to the second subnode.
[0078] In some specific embodiments, after the sub-node creation module 12, the following may also be included:
[0079] A second setting unit, configured to set the maximum height of the first subnode to be twice the height of the target display area;
[0080] The second subnode moving unit is used to move the second subnode upwards by a distance twice the height of the target display area.
[0081] In some specific embodiments, the sub-node adding module 14 may specifically include:
[0082] an attribute adding unit, configured to add a title attribute to the second child node if the width of the target text exceeds the width of the target display area;
[0083] The sub-node adding unit is used to add a third sub-node in the rear half of the display area of the second sub-node by using the positioning attribute.
[0084] In some specific embodiments, after the display module 16, the following may also be included:
[0085] The text content display unit is used to display the complete content of the target text in the tool tip text when it is detected that the mouse moves into the target display area.
[0086] In some specific embodiments, the display module 16 may specifically include:
[0087] A text display unit is used to display the target text in the second sub-node and the third sub-node in the order of selecting a field of the first preset width from the beginning, an ellipsis, and selecting a field of the second preset width from the end; wherein the sum of the first preset width, the second preset width and the width of the ellipsis is equal to the width of the target display area.
[0088] Furthermore, the present application also discloses an electronic device. Fig.11 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0089] Fig.11 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the text display method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0090] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0091] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0092] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the text display method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0093] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed text display method. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, and no further description will be given here.
[0094] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0095] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0096] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0097] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0098] The above is a detailed introduction to a text display method, device, equipment and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A text display method, characterized in that: include: Determine the target display area for displaying the target text in the Web front-end page; Creating a first subnode and a second subnode for displaying the target text in the target display area, and setting the elements in the first subnode and the second subnode as block-level elements; Determine whether the width of the target text exceeds the width of the target display area; If the width of the target text exceeds the width of the target display area, a third subnode is added to the second half of the display area of the second subnode using the positioning attribute, and the text display mode in the third subnode is set to be from back to front, and the text exceeding the display area of the third subnode is set to ellipsis, and finally the target text is displayed in the second subnode and the third subnode; After setting the elements in the first subnode and the second subnode as block-level elements, the method further includes: setting the maximum height of the first subnode to twice the height of the target display area; The second child node is moved upward by a distance twice the height of the target display area.
2. The text display method according to claim 1, characterized in that: Before creating the first sub-node and the second sub-node for displaying the target text in the target display area, the method further includes: The line height of the target display area is set to be the same as the height of the target text by using a cascading style sheet, and the text exceeding the target display area is set to be invisible.
3. The text display method according to claim 2, characterized in that: The step of creating a first sub-node and a second sub-node for displaying the target text in the target display area includes: Creating a first sub-node and a second sub-node for displaying the target text in the target display area; The second subnode is moved below the first subnode; wherein the first subnode is adjacent to the second subnode.
4. The text display method according to claim 1, characterized in that: If the width of the target text exceeds the width of the target display area, adding a third sub-node in the rear half of the display area of the second sub-node by using the positioning attribute includes: If the width of the target text exceeds the width of the target display area, a title attribute is added to the second child node, and a third child node is added to the rear half of the display area of the second child node using a positioning attribute.
5. The text display method according to claim 4, characterized in that: After displaying the target text in the second sub-node and the third sub-node, the method further includes: When it is detected that the mouse moves into the target display area, the complete content of the target text is displayed in the tooltip text.
6. The text display method according to any one of claims 1 to 5, characterized in that: The step of displaying the target text in the second sub-node and the third sub-node includes: The target text is displayed in the second sub-node and the third sub-node in the order of selecting a field of the first preset width from the beginning, an ellipsis, and selecting a field of the second preset width from the end; wherein the sum of the first preset width, the second preset width and the width of the ellipsis is equal to the width of the target display area.
7. A text display device, characterized in that: include: A display area determination module is used to determine a target display area for displaying target text in a Web front-end page; A subnode creation module, used to create a first subnode and a second subnode for displaying the target text in the target display area, and set the elements in the first subnode and the second subnode as block-level elements; A judging module, used to judge whether the width of the target text exceeds the width of the target display area; A sub-node adding module, used for adding a third sub-node to the rear half of the display area of the second sub-node by using a positioning attribute if the width of the target text exceeds the width of the target display area; A setting module, used to set the display mode of the text in the third sub-node to be from back to front, and set the text beyond the display area of the third sub-node to be ellipsis; A display module, used for displaying the target text in the second sub-node and the third sub-node; The device is further used to set the maximum height of the first sub-node to twice the height of the target display area; and move the second sub-node upward by a distance twice the height of the target display area.
8. An electronic device, characterized in that: It comprises a processor and a memory; wherein, when the processor executes the computer program stored in the memory, the text display method as claimed in any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein, when the computer program is executed by a processor, the text display method according to any one of claims 1 to 6 is implemented.
