When making a table page, sometimes the width set for td is invalid. The width of td is always expanded by the internal content. You can set padding, but setting width directly is invalid. Let's take a closer look at this example: Copy code The code is as follows:<div> <table border="1px"> <tr> <td width="100px" style="width: 100px !important;">1000800</td> <td>1000000</td> <td>1000000</td> </tr> <tr> <td>1000000</td> <td>10000300</td> <td>1000000</td> </tr> </table> </div> <table border="1px"> <tr> <td width="100px">1000000</td> <td>1000000</td> <td>1000000</td> </tr> <tr> <td>1000000</td> <td>10000300</td> <td>1000000</td> </tr> </table> * {margin: 0; padding: 0;} .div1 {position: relative; width: 150px; height: 100px; overflow: scroll; border: 1px solid red;} ![]() We can see that although the width of the first cell in class div1 is set, it is invalid. The cell content is always determined by the content. Since it is determined by the content, we should find a way to let the "content" expand the cell. That's it. We can add a div in td and set the width of the div. Let's try it: Modify part of the code in class div1: Copy code The code is as follows:<td width="100px" style="width: 100px !important;">1000800</td> Modified to Copy code The code is as follows:<td><div>1000800</div></td> Then write in the style: Copy code The code is as follows:td div { width:100px; } Refresh the page, and the effect is as follows: ![]() We can see that the width of the cells in class div1 has taken effect. |
<<: How to make a tar file of wsl through Docker
>>: Example code for building an admin dashboard layout using CSS and JavaScript
This article shares the specific code of jQuery t...
Table of contents Problem description: Installati...
1. Docker startup problem: Problem Solved: You ne...
Recorded the installation of mysql-8.0.12-winx64 ...
Table of contents Mainly used Postman functions D...
Let me first talk about the implementation steps:...
1. Environment: MySQL-5.0.41-win32 Windows XP Pro...
Table of contents Overview Why choose a framework...
The main function of a calculator is to perform n...
How to obtain SQL statements with performance iss...
Often you will encounter a style of <a> tag...
Table of contents Preface Case: Imitation of JD.c...
The specific code for JavaScript to implement the...
The detailed process of using MySQL database with...
Install Nginx First pull the centos image docker ...