Table related arrangement and Javascript operation table, tr, td

Table related arrangement and Javascript operation table, tr, td
Table property settings that work well:

Copy code
The code is as follows:

<table cellSpacing="0" cellPadding="0" border='1' bordercolor="black"
style='border-collapse:collapse;table-layout: fixed'></table>

Many people have had this experience: when there is no content or no visible elements in a td, the border of the td will also disappear. The solution is to add the style border-collapse:collapse to the table
General text truncation (applies to both inline and block):

Copy code
The code is as follows:

.text-overflow{
display:block;/*Inline objects need to be added*/
width:31em;
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;. */
}

For tables, the definition is a little different:

Copy code
The code is as follows:

table{
width:30em;
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;. */
}

Javascript operations table, tr, td

Copy code
The code is as follows:

table.moveRow(m,n) //Exchange the rows of the table (IE) The rows between m and n are moved in sequence
table.deleteRow(index) // row deletion
table.insertRow(index) //Insert a row at index and return the TR
tr.insertCell(index) //Insert a cell and return the TD
tr.deleteCell(index)
tr.rowIndex // Returns the position of tr in the table
td.cellIndex //Return the position of td in tr

<<:  25 Examples of News-Style Website Design

>>:  Use CSS to draw a file upload pattern

Recommend

Detailed explanation of the wonderful uses of SUID, SGID and SBIT in Linux

Preface Linux's file permission management is...

Specific usage of CSS compound selectors

Intersection Selector The intersection selector i...

How to enable JMX monitoring through Tomcat

Build a simulation environment: Operating system:...

Turn off the AutoComplete function in the input box

Now we can use an attribute of input called autoco...

Detailed explanation of JavaScript error capture

Table of contents 1. Basic usage and logic 2. Fea...

calc() to achieve full screen background fixed width content

Over the past few years, there has been a trend i...

Use xshell to connect to the Linux server

Benefits of using xshell to connect to Linux We c...

Implementing custom radio and check box functions with pure CSS

1. Achieve the effect 2 Knowledge Points 2.1 <...

Docker image loading principle

Table of contents Docker images What is a mirror?...

Three ways to share component logic in React

Without further ado, these three methods are: ren...

React implements dynamic pop-up window component

When we write some UI components, if we don't...

5 ways to migrate Docker containers to other servers

Migration is unavoidable in many cases. Hardware ...

How to hide rar files in pictures

You can save this logo locally as a .rar file and...

HTML scroll bar textarea attribute setting

1. Overflow content overflow settings (set whether...

Ten popular rules for interface design

<br />This is an article I collected a long ...