Solution to overflow of html table

Solution to overflow of html table

If the table is wide, it may overflow.

For example, there are two divs, left and right. If the table is in the div on the right, but it is wider, it is likely that it will not be displayed in the div on the right, but will be displayed at the bottom. At this point, you only need to specify the width of the table:


Copy code
The code is as follows:

<table style='width:85%'>

Solve the problem that the content in the HTML table does not force line breaks and automatically hides and displays ellipsis when it exceeds the width

In table layout, we often encounter situations where the layout is chaotic due to changes in the length of the table content. At this time, we may set the cell width to be fixed for layout stability; but when we set the width, we find that it will automatically increase after exceeding the width, and using CSS to define the overflow:hidden; attribute of the element does not work either. The final solution is as follows:

table{
   
    table-layout:fixed;/* The following td definition will work only if the table layout algorithm is defined as fixed. */
}
td{
    width:100%;
    word-break:keep-all;/* No line break*/
    white-space:nowrap;/* No line break*/
    overflow:hidden;/*Hide the excess content when the content exceeds the width*/
    text-overflow:ellipsis; /* Displays an ellipsis mark (...) when the text overflows within an object; must be used together with overflow:hidden;. */
}

If you are worried that you cannot see the complete cell content after it is hidden, it is recommended to add the title attribute value to the cell, which is the complete content of the cell. This way, you can display all of it as long as the mouse passes over it.

<<:  Notes on upgrading to mysql-connector-java8.0.27

>>:  Pricing table implemented with CSS3

Recommend

Vue implements a simple marquee effect

This article shares the specific code of Vue to a...

Dynamic SQL statement analysis in Mybatis

This article mainly introduces the dynamic SQL st...

A brief discussion on the VUE uni-app development environment

Table of contents 1. Through HBuilderX visual int...

Vue implements the drag and drop sorting function of the page div box

vue implements the drag and drop sorting function...

Detailed explanation of how to use JavaScript paging component

The pagination component is a common component in...

MySQL master-slave replication principle and points to note

Written in front I have been writing a special to...

Website redesign is a difficult task for every family

<br />Every family has its own problems, and...

Vue3.0 uses the vue-grid-layout plug-in to implement drag layout

Table of contents 1. Plugins 2. Interlude 3. Impl...

Detailed explanation of MySQL binlog usage

binlog is a binary log file that records all DML ...

Analysis of MySQL's planned tasks and event scheduling examples

This article uses examples to describe MySQL'...

Search engine free collection of website entrances

1: Baidu website login entrance Website: http://ww...

Form submission page refresh does not jump

1. Design source code Copy code The code is as fol...

JavaScript implements the nine-grid mobile puzzle game

This article shares the specific code for JavaScr...

MySQL 8.0 user and role management principles and usage details

This article describes MySQL 8.0 user and role ma...