Home  >  Article  >  Web Front-end  >  The width setting of the table cell td is invalid and the internal content is always stretched_HTML/Xhtml_Web page production

The width setting of the table cell td is invalid and the internal content is always stretched_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:37:471498browse

When making table pages, sometimes the width set for the td is invalid. The width of the td is always stretched by the internal content. You can set padding, but setting the width directly is invalid. Let’s take a look at this example in detail:

Copy code
The code is as follows:








< /td>


1000800 1000000
1000000
10000001000000





;


td>

1000000 1000000
1000000

* {margin: 0; padding: 0;}
.div1 {position: relative; width: 150px; height: 100px; overflow: scroll; border: 1px solid red;}




We can see that although the first cell in class div1 has a width set, it is invalid. . The content of the cell is always determined by the content, so since it is determined by the content, we have to find a way to let the "content" expand the cell, and that's it.

We can add a div in td, and then 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: 1000800
is modified to




Copy the code
The code is as follows:
1000800
Then write in the style:




Copy code
The code is as follows: td div {
width:100px;
}


Refresh the page, the effect is as follows:

We can see that the width of the cell in class div1 has taken effect.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn