首页 > 解决方案 > Bootstrap 4 表 td 宽度尺寸自定义

问题描述

我需要增加评分栏的宽度,但我的 w-9 不起作用。我想扩大评分栏。

这是我的桌子

这是我的表格代码:

 <table class="table table-bordered stick-top">
                <thead class="text-center" id="data">
                    <tr>
                        <th></th>
                        <th>Questions</th>
                        <th id="try">Rating</th>
                    </tr>
                </thead>
                <tbody class="body_data">
                    <?php 
                        $jio=mysqli_query($conn,"SELECT * FROM question")or die ("error");
                        while(list($Question_ID,$Question_Description)=mysqli_fetch_array($jio))
                        { ?>
                            <tr>
                            <td><?php echo $Question_ID; ?></td>
                            <td><?php echo $Question_Description; ?> </td>

                            <?php
                            $q1 = "SELECT * FROM rating ORDER BY Rating_ID ASC";
                            $r1 = $conn -> query($q1);
                            echo "<td class='w-9'";
                            while($row = $r1 -> fetch_object()){
                                echo "<input id='radio' type='radio' name='radio$Question_ID' value='" . $row -> Rating_ID . "' required>". $row -> Rating_ID;"";
                            }
                            echo "</td>";
                             ?>
                            </tr>
                        <?php } ?>

                </tbody>
            </table>

标签: phpcsshtml-tablebootstrap-4

解决方案


如果您在Sizing doc中查看 Bootstrap Doc, 您会发现它们已包含对25%、50%、75%、100% 和 auto的支持,所以基本上当您使用w-9该类时为空

因此,如果您无法修改 css 文件,则需要将以下属性放在 td 标签内:

<td  style="width:9%">

推荐阅读