The width of table, cells made of concatenated strings cannot be controlled.

Table:

< table > < thead > < tr > < th > a < / th > < th > b < / th > < th > c < / th > < th > d < / th > < th > e < / th > < / tr > < / thead > < tbody class= "getTableData" > < tr > < th > 1 < / th > < th > 22222222222222222222222222222222222 < / th > < th > 333333333333333 < / th > < th > 44444444444 < / th > < th > 55555555555555555555555555555555555555555555555555555555 < / th > < / tr > < / tbody > < / table > In

tbody, the data is concatenated into the string in the ajax callback. Because the content length of b is longer, the width of the cell is longer.

it doesn"t work if I add width to th or td.
is there a boss who knows how to make the width work? I hope the content in the cell exceeds that of line wrapping.

Jun.22,2021

Hello friend, I have written a demo, and hope it will be helpful to you! Mainly make use of table-layout:fixed; and word-break: break-all; , welcome to exchange what is not clear!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        table{
            table-layout:fixed;
            width: 300px;
            border: 1px solid pink;
        }
        td{
            border: 1px solid pink;
            word-break: break-all;
        }
    </style>
</head>
<body>
    <table>
        <tr>
            <td>11111111111111</td>
            <td>22222222222222222222222</td>
            <td>33333333</td>
        </tr>
        <tr>
            <td>11111111111111</td>
            <td>22222222222222222222222</td>
            <td>33333333</td>
        </tr>
        <tr>
            <td>11111111111111</td>
            <td>22222222222222222222222</td>
            <td>33333333</td>
        </tr>
    </table>
</body>
</html>

table {table-layout:fixed;}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b22520-2b5f8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b22520-2b5f8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?