html - jQuery DataTables 中的水平滚动

标签 html css datatables

我有一个提供 jQuery DataTables 功能的模板。但我无法水平滚动表格。当我添加列时,它们就不会出现在 View 中

下面是HTML代码

    <h3>Trainer Deletion</h3>
    <div class="table-responsive">
        <table id="example-datatable" class=" table-condensed table-bordered">
            <thead>
                <tr>
                                <th></th>
                                <th>Trainer ID</th>
                                <th>Name</th>
                                <th>Gender</th>
                                <th>Age</th>
                                <th>Description</th>
                                <th>Primary Mobile Number</th>
                                <th>Secondary Number</th>
                                <th>Base City</th>
                                <th>Base Location</th>
                                <th>Work Location</th>
                                <th>Education</th>
                                <th>Trainer Since</th>
                                <th>ID Proof</th>
                                <th>Certificates</th>
                                <th>Email</th>
                                <th>Email Verify</th>
                                <th>Not Available on</th>
                                <th>Style</th>
                </tr>
            </thead>
            <tbody>
                <?php
                    include("db.php");
                                $sql="select * from trainer";
                                $result=mysqli_query($conn, $sql);                      
                ?>
                <?php while($row=mysqli_fetch_array($result)) { ?>
                <tr>
                    <td class="text-center"><?php echo"<input type='checkbox' name=id[] value='$row[trainer_id]'>"; ?></td>
                    <td class="text-center"><?php echo"$row[trainer_id]";?></td>
                    <td class="text-center"><?php echo"$row[Name]";?></td>
                    <td class="text-center"><?php echo">$row[Gender]";?></td>
                    <td class="text-center"><?php echo"$row[Age]";?></td>
                    <td class="text-center"><?php echo"$row[Description]";?></td>
                    <td class="text-center"><?php echo"$row[Primary_mobile_number]";?></td>
                    <td class="text-center"><?php echo"$row[Secondary_number]";?></td>
                    <td class="text-center"><?php echo"$row[Base_city]";?></td>
                    <td class="text-center"><?php echo"$row[Base_Location]";?></td>
                    <td class="text-center"><?php echo"$row[Work_location]";?></td>
                    <td class="text-center"><?php echo"$row[Education]";?></td>
                    <td class="text-center"><?php echo"$row[Trainer_since]";?></td>
                    <td class="text-center"><?php echo"$row[Id_proof]";?></td>
                    <td class="text-center"><?php echo"$row[Certificates]";?></td>
                    <td class="text-center"><?php echo"$row[email]";?></td>
                    <td class="text-center"><?php echo"$row[email_verify]";?></td>
                    <td class="text-center"><?php echo"$row[not_available_on]";?></td>
                    <td class="text-center"><?php echo"$row[Style]";?></td>
                </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>

下面是截图

enter image description here

最佳答案

如果你添加:

style="overflow-x:auto;"

<div style="overflow-x:auto;" class="table-responsive">

当它与容器重叠时,该显示允许您滚动。

关于html - jQuery DataTables 中的水平滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31470946/

相关文章:

javascript - 从文件上传设置div背景图片

javascript - 如何防止特定的 child 使用 Jquery 进行事件绑定(bind)?

html - 完成后 CSS 文本转换恢复为字体大小

javascript - jQuery click 函数只执行一次

css - 如何让视频下的H标签和P标签响应

javascript - 多选分层下拉

html - 相对于图像定位文本

ajax - Datatables 1.10.5 ajax 错误处理程序 - 访问 http 状态代码

css - 样式化 Bootstrap 数据表搜索过滤器

javascript - 使用indexOf匹配的JS代码是如何工作的?