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
export default ({ url, method = 'GET', da...
Currently, layui officials have not provided the ...
Recently, when I was using the Linux operating sy...
1. Create a new virtual machine in VMware 15.5 1....
Local Windows remote desktop connects to Alibaba ...
Rendering Commonly used styles in Blog Garden /*T...
The environment of this article is Windows 10, an...
1. Introduction to Docker 1.1 Virtualization 1.1....
Table of contents Component Infrastructure Purpos...
This article shares the installation tutorial of ...
1: nginx server solution, modify the .conf config...
1: Docker private warehouse installation 1. Downl...
This article describes how to boot the Linux syst...
XHTML defines three document type declarations. T...
One of the most important features of a style she...